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
 Forum for Origin C
 create matrix without using a template

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
Dr.Klein Posted - 03/17/2004 : 6:15:53 PM
Hello everybody !

Could it be that it is not possible to create a matrix with OriginC without using a template ?
When you replace
mat1.Create("origin");
in this sample code from the help-files:

void fillMatrix()
{
MatrixPage mat1;
mat1.Create("origin");
mat1.Rename("myMatrix");
Matrix <double> aa;
BOOL bRet = aa.Attach("myMatrix");
UINT rows = aa.GetNumRows();
UINT cols = aa.GetNumCols();
printf("rows = %d\t cols = %d\n", rows, cols);
for (int ii = 0; ii<rows; ii++)
for (int jj = 0; jj<cols; jj++)
{
aa[ii][jj]= sin (ii) + cos (jj);
}
}

by
mat1.Create();
the created 10x6 matrix is empty.

I don't want to create a different template all the time.I know the number of rows and columns of the Matrix I want to create.
And the cells of the matrix should be filled with the values of a dataset, like:

aa[i][j]=ds[j+nCols*i]; //aa is the matrix, ds the dataset, nCols
// the number of columns
Is it possible to modify the example above for this ?

Thank you

Oliver
3   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 08/21/2006 : 08:00:27 AM
Hi Brad,

Declare pat as Matrix rather than matrix...

Matrix pat("pattMatrix");
pat.SetSize(XRANGE,YRANGE);

Mike Buess
Origin WebRing Member
btink Posted - 08/20/2006 : 2:09:59 PM
Hello.

I am having a problem inputting data from a loop into a matrix. Once I have successfully created the matrix I will need to make a contour plot; I like to automate this as well using origin C.

I am able to compile and run my program. The worksheets are all created and labeled correctly, but the matrix that is created remains empty. I am not sure that I am yet clear on the distinctions between matrix objects,layers, etc.

For simplicity I have only included part of the program. The vectors (Vf,Vk,Vy,xp,yp)in the loop, as well as nrows, are defined earlier. I can send the rest of the program and the input file if necessary.

kind regards, Brad


#define XRANGE 20
#define YRANGE 100

MatrixPage mat1; // Define MatrixPage (for labeling purposes?)
mat1.Create("origin"); // Create MatrixPage
mat1.Rename("pattMatrix"); //label MatrixPage
double mod;
int i,j,k;
matrix <double> pat(XRANGE,YRANGE); // Define Matrix
// BOOL bRet = pat.Attach("pattMatrix"); // this line produces error ?


for (i = 0; i < XRANGE; i++) // perform calculation
{
for (j = 0; j < YRANGE; j++)
{
for (k = 0; k < nrows; k++)
{

mod = Vf[k]*Vf[k];

pat[i][j] = mod*(cos(2*PI*(Vh[k]*xp[i]+Vk[k]*yp[j])));


}
}
}


}


cpyang Posted - 03/17/2004 : 6:33:38 PM
You will need to specify a template, but can just always use "Origin" which is the default tempalte. After create, you can call SetSize to set the rows and cols.

Currently, if you create a matrix page without a template, the created MatrixLayer has no MatrixObject and you will need to Add a new matrix object, but the command to add MatrixObject is not yet implemented in our current released versions.

CP



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