The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 matrix -v limit of expression length

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
SteffenG Posted - 06/24/2005 : 04:51:06 AM
Origin Version (7.5G SR5):
Operating System: Win XP Pro

Hi,

I have a problem with the length of the expression in the command "matrix -v expression". If the expression is too long (> approx. 300 chars) Origin crashes. Is there a work around or a patch for this problem?

I know I can try a function definition in Origin C to avoid this problem but the expression uses the variables X and Y from the matrix and I dont know how to access this variables in Origin C.

I would prefer if there is a way in Labtalk to deal with the problem.

Kind regards
Steffen
3   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 06/24/2005 : 10:05:38 AM
Hi Steffen,

Looks like you've reached a fundamental limitation to LabTalk's matrix command. Note that you can also set matrix values based on X and Y in Origin C. See Matrix::SetCellValue. You feed in x and y values and a cell value and OC finds the nearest cell and sets it's value. There should be no limits to that approach.

...You can combine OC with matrix -v to avoid the necessity of looping over all cells in Origin C.

// OC function
double setMatrix(double x, double y)
{
double dValue;
dValue = x*y; // substitute your expression here
return dValue;
}

// LT command
matrix -v setMatrix(x,y);

...Here is the full OC solution which sets each cell separately. Run it with the matrix active, SetMatrixValues(%H). I didn't notice much difference in performance (speed) between this and the matrix -v setMatrix method with the expression x*y.
void SetMatrixValues(string matName)
{
double x,y,dValue;
Matrix mm(matName);
for(int i=0;i<mm.GetNumCols();i++)
{
x = mm.GetXValue(i);
for(int j=0;j<mm.GetNumRows();j++)
{
y = mm.GetYValue(j);
dValue = x*y; // substitute your expression here
mm.SetCellValue(x,y,dValue);
}
}
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 06/24/2005 12:12:31 PM

Edited by - Mike Buess on 06/24/2005 12:13:02 PM

Edited by - Mike Buess on 06/24/2005 3:14:47 PM
SteffenG Posted - 06/24/2005 : 09:20:23 AM
Hi Mike,

thanks for your reply. But I don't use a variable to hold the expression. I wrote the expression right after the matrix -v command.

I tried your suggestion to use the variable %Z to hold the expression but Origin crashed also.

Do you have other hints for that?

Up to now I fill two matrices with a half of the expression and after that I add one matrix to the other. But this isn't nice because of the working speed.

Best regards,
Steffen
Mike Buess Posted - 06/24/2005 : 09:07:48 AM
Hi Steffen,

I don't know if the 300 char limit is built in the matrix command but it is built in to letter variables like %A, %B, etc. If you assign your expression to a letter variable like this...

%A="expression";
matrix -v %A;

then it will be truncated which could explain the crashes. If that's the case use the %Z variable instead because it can hold approx 8000 chars.

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000