The Origin Forum
File Exchange
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
 Help for matrix data processing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

redman

UK
46 Posts

Posted - 06/08/2012 :  09:19:01 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!

Penn

China
638 Posts

Posted - 06/11/2012 :  04:59:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please try the GetDataObject method.

Penn
Go to Top of Page

redman

UK
46 Posts

Posted - 06/11/2012 :  05:35:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

Penn

China
638 Posts

Posted - 06/12/2012 :  02:25:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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 © 2008 Originlab Corporation Go To Top Of Page
Snitz Forums 2000