The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to record individual timestep data in Simulink?
Replies: 10   Last Post: Sep 5, 2012 2:04 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Kate J.

Posts: 177
Registered: 6/9/11
Re: How to record individual timestep data in Simulink?
Posted: Sep 4, 2012 3:06 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Thanks for your suggestion, Phil. It makes sense to me. However, when I had the chance to try it out, I found that while the syntax ?mxSetPr(array_ptr, &varMEX);? allows the code to compile, it actually causes a crash when the system runs. (If I comment out this line, the code runs with no problems.) If my code is given below, any suggestions about what else could be the issue, such that running this code results in crash behavior? Thanks.

mxArray *array_ptr;
double varMEX;

array_ptr = mxCreateDoubleMatrix(1,1,mxREAL);
array_ptr = mexGetVariable("base","Timestep");
varMEX = mxGetPr(array_ptr)[0];


if(varMEX < value){

/* all code above this point works */

/* problematic part: returning the value to the base workspace */

varMEX = 100.0; /* reset varMEX to arbitrary value */
mxSetPr(array_ptr, &varMEX); /* causes a crash */

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.