Plot x-axis and y-axis with mexCallmatlab
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
In my S-function written in C I use the function mexCallmatlab to plot the content of an array and it works as I want:
real_T Gain[205];
// Some code to fill the array Gain
// convert array to mxArray
mxArray* x_ptr_gain; // Pointer
x_ptr_gain = mxCreateDoubleMatrix(1, 205, mxREAL);
memcpy(mxGetPr(x_ptr_gain), Gain, sizeof(double)*205);
mexCallMATLAB(0,NULL,1,&x_ptr_gain,"plot");
Matlab plots on the y-axis the content of my array and on the x-axis the vector number 1,2…205.
Now I would like to have on the x-axis the content of an other vector freq, which has of course the same size than Gain:
real_T freq[205];
What do I have to change to get want I want? I tried a few things, but as I am not very sure how all these structures work, I may have done mistakes and giving me the solution would be really nice :)
Thanks.
0 件のコメント
採用された回答
Kaustubha Govind
2013 年 8 月 26 日
// Copy freq into an mxArray x_ptr_freq
mxArray* x_ptr_freq = mxCreateDoubleMatrix(1, 205, mxREAL);
memcpy(mxGetPr(x_ptr_freq), freq, sizeof(double)*205);
...
mxArray *prhs[2] = {x_ptr_freq, x_ptr_gain};
mexCallMATLAB(0,NULL,2,prhs,"plot");
...
// Cleanup
mxDestroyArray(x_ptr_freq);
mxDestroyArray(x_ptr_gain);
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!