Arrays as input signals for CMEX function

2 views (last 30 days)
Rob
Rob on 11 Aug 2014
Edited: Rob on 11 Aug 2014
Hi, I really searched Google, the MATLAB Online Docs and the MATLAB Answers for this, but didn't get any result.
I need to accept a dynamically sized array as input signal for my CMEX SFunction. I copied the example from the ssGetInputPortSignal online description and it just threw an error because of this line:
UseInputInSomeFunction(*u[j]);
When I compile, it says:
error C2100: illegal indirection
It gets the width correctly, but fails in accessing the array.. Even if I force the indirection by casting to a double pointer or stuff, MATLAB crashes because of an access violation (of course...). I did not find one single example on how to access elements of an array. Please, please, provide one. It can't be that hard :-P
Thank you very much!!
EDIT:
I changed the code and inserted output and it turns out that every 2n-1 element in the array has the value 0:
Code:
const real_T **u1 = (const real_T**) ssGetInputPortSignal(S,1);
for (int i=0;i<(int)ssGetInputPortWidth(S, 1);i++) {
std::cout << u1[i] << "," << std::flush;
}
std::cout << ")" << std::endl;
Output:
u1 width: 10
u1 elements: (00000000,3FF00000,00000000,40000000,00000000,40080000,00000000,40100000,00000000,40140000,)
Btw:
std::cout << *u1[i]
still gives me the compiler error C2100 or (if I do some tricks to get rid of the compiler error) causes MATLAB to crash...

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!