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
 Help for matrix data processing

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
redman Posted - 06/08/2012 : 09:19:01 AM
Origin Ver.8.6 and Service Release (Select Help-->About Origin): SR3
Operating System: Windows 7 x64

I'm trying to do some calculations based on matrix data. However, I experienced "data type mismatch" error using the following test codes on any matrix data type other than double type:

void testme()
{
MatrixLayer mlay = Project.ActiveLayer();
Matrix TestMatrix(mlay);
int nNumCols=TestMatrix.GetNumCols();
int nMatrixRows=TestMatrix.GetNumRows();
printf("test1= %d\n", nint(TestMatrix.GetCellValue(nMatrixRows-1, nNumCols-1)));//it depends on x, y mapping.
printf("test2= %d\n", nint(TestMatrix[nNumCols-1][nMatrixRows-1]));
}

Is there a common way to access the cell value disregards the matrix data type, i.e. directly read the pixel value of an image, or read the corresponding cell value from an matrix data (char(1)/short(2)), or get a cell value from an matrix with a data type of double?

Thanks for your help in advance!
3   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 06/12/2012 : 02:25:56 AM
Hi,

The GetCellValue method is for Matrix class, and the matrix class (different from Matrix class) has no such method. So, if you want to use the GetCellValue, you have to use the Matrix class. Actually, you can specify the data type for it. For example:

Matrix<short> TestMatrix(mlay);  // not sure what type you want, here use short for example


Penn
redman Posted - 06/11/2012 : 05:35:05 AM
Many thanks! Finally, I solved the problem by using the matrix objcets:

void testme()
{
MatrixLayer mlay = Project.ActiveLayer();
if(!mlay) return;
MatrixObject mObj=mlay.MatrixObjects(0);
matrix TestMatrix(mObj);
int nNumCols=TestMatrix.GetNumCols();
int nMatrixRows=TestMatrix.GetNumRows();
printf("last cell = %d\n", nint(TestMatrix[nMatrixRows-1][nNumCols-1]));
}

But the code of TestMatrix.GetCellValue(nMatrixRows-1, nNumCols-1) does not work any more.
Penn Posted - 06/11/2012 : 04:59:55 AM
Hi,

Please try the GetDataObject method.

Penn

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