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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 matrix -v limit of expression length
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

SteffenG

Germany
Posts

Posted - 06/24/2005 :  04:51:06 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Mike Buess

USA
3037 Posts

Posted - 06/24/2005 :  09:07:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

SteffenG

Germany
Posts

Posted - 06/24/2005 :  09:20:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/24/2005 :  10:05:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000