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