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
 Origin Forum
 Setting cell values in a matrix

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
ecerda Posted - 01/03/2011 : 08:03:14 AM
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!

1   L A T E S T    R E P L I E S    (Newest First)
Sam Fang Posted - 01/04/2011 : 02:19:31 AM
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

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