Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: mexCallMATLAB crashes in loops?
Replies: 12   Last Post: Jan 3, 2013 1:49 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yi

Posts: 6
Registered: 12/28/12
Re: mexCallMATLAB crashes in loops?
Posted: Jan 2, 2013 5:36 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Thank you, James. Actually I only need one of the structure element each time for the function input, and I was messing up when setting the field values for the incall.

I fixed the code in this way:

:
for(istruct=0;istruct<ninputs;istruct++){

for(ifield=0; ifield<nfields; ifield++){
tmp=mxDuplicateArray(mxGetFieldByNumber(prhs[0],istruct,ifield));
mxSetFieldByNumber(incall[0], 0, ifield, tmp);
}
:
mxDestroyArray(mout[0]);
}

I got some ideas from this thread:
http://www.mathworks.co.kr/matlabcentral/newsreader/view_thread/280511

So I cleaned the mout[0] in each loop and cleaned the incall[0] in the end. The code works for now yet I still have a question:

Is it necessary to clean the mout[0] in the loop? Can I clean it up in the end of the code (with incall[0])?

Thank you again for your helpful replies :)



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.