MATLAB Coder return vector or matrix
显示 更早的评论
I have made a simple function to do a calculation and return a matrix. Using MATLAB Coder I intent to use the compiled code in iOS as per the webinar here http://www.mathworks.se/videos/matlab-to-iphone-made-easy-90834.html?form_seq=conf1008&confirmation_page&wfsid=5912317
However, my question is, how do I return the matrix in my Xcode project?
Right now my MATLAB script is called
function A = myFunction()
where A is a 6x6 matrix initialized with zeros for now.
When generating the C code my function will look something like
void myFunction(double A[36])
If, for starters, I just wanted to output the matrix data containing zeros in Xcode, how would I go about this?
What I have tried is to import the compiled .c/.h files, call the initialization i.e.
myFunction_initialize()
Then to get the data, call the function
double A;
myFunction(&A);
NSLog(@"A: %f",A);
However, this returns an error "error: memory read failed for 0x0", so either I have set up something in the wrong way in MATLAB or I am not initializing and/or using it correctly in Xcode, I guess both. I tried to setup my script to return a single value and then it actual sets up a return type in the code. With the matrix however, the return type is void.
Have not been able to find any information, tutorials or examples on the matter, so any help would be much appreciated.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!