I'm trying to plot data out from a MEX file (C language). To do this fast, I would like to use what corresponds to the following Matlab code:
figure; imagehandle = imagesc(rand(500));
new_CData = rand(500);
set(newCData,imagehandle);
For this, the command mexSet() should be working. Ideally, I want something like this
mex plotX.c
figure; imagehandle = imagesc(rand(500));
A = rand(500);
plotX(A,imagehandle)
with a mex-Function plotX. Here is my tryout:
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double *x, imagehandle;
(void) plhs;
x = mxGetPr(prhs[0]);
imagehandle = mxGetScalar(prhs[1]);
mexSet(imagehandle,"Cdata",x);
}
This can be compiled, but I get the following error: "Error using plotX. Numeric or logical matrix required for image CData".
What am I doing wrong? I've asked the same question at Stackoverflow, but got no answer.
Best, Peter