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
 Forum for Origin C
 create matrix without using a template
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Dr.Klein

Germany
Posts

Posted - 03/17/2004 :  6:15:53 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

cpyang

USA
1406 Posts

Posted - 03/17/2004 :  6:33:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page

btink

Germany
8 Posts

Posted - 08/20/2006 :  2:09:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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])));


}
}
}


}


Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/21/2006 :  08:00:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Brad,

Declare pat as Matrix rather than matrix...

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

Mike Buess
Origin WebRing Member
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