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
 Origin Forum
 Setting cell values in a matrix
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ecerda

6 Posts

Posted - 01/03/2011 :  08:03:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: OriginPro 8.1 SR3
Operating System: Windows 7

I need to change one column of a matrix with many Matrix Objects. I use as a reference the example given in the Help file for "matrix"

void matrix_matrix_ex5()
{
MatrixObject mo("MBook1", 0);

matrix m(mo, TRUE);


int nRows, nCols;
if (m.GetSourceDim(nRows, nCols))
printf("rows = %d\tcols=%d\n", nRows, nCols);

// Change the size and set new values:
m.SetSize(7, 9);
for (int row = 0; row < m.GetNumRows(); row++)
{
for (int col = 0; col < m.GetNumCols(); col++)
{
m[row][col] = (row + 1) * (col + 1);
}
}

}

I run this example but it just simpliy does not work: the matrix MBook1 does not change at all.

Thank you for your help!

Sam Fang

293 Posts

Posted - 01/04/2011 :  02:19:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
An Origin C matrix class is not tied to an internal Origin matrix. You should use an Origin C Matrix class instead, which is tied to an internal Origin matrix, and you can use it to change Matrix Objects. You can change your beginning script as follows.
--------------------------------------------------------------
void matrix_matrix_ex5()
{
    MatrixLayer ml;
    ml = (MatrixLayer) Project.ActiveLayer(); 
    Matrix m(ml, 0);
	
    int nRows, nCols;
    nRows = m.GetNumRows();
    nCols = m.GetNumCols();

...
}

--------------------------------------------------------------

Sam
OriginLab Technical Services

Edited by - Sam Fang on 01/04/2011 03:34:11 AM
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