using get_Param inside an S-function

function [sys]= mdlOutputs(t,x,u,flag,Label)
tSTOP = get_param('Model','StopTime');
if(tSTOP == (1000*ceil(t/1000)))
fclose(FID);t
end
sys = [];
return;
end
tSTOP is not seen inside the 'if' loop. The value of 't' does not get printed out. If I replace tSTOP with the numerical value of tTSOP it works fine. Any help is appreciated.

3 commentaires

Aswartha Narayana
Aswartha Narayana le 28 Nov 2011
How do I convert the output of get_Param to make it suitable for use in 'if' loop. Using 'round' did not work.
Aswartha Narayana
Aswartha Narayana le 28 Nov 2011
using str2num did work; the output of get_param here appears to be a string.
Walter Roberson
Walter Roberson le 8 Déc 2011
There is no such thing as an if loop.

Connectez-vous pour commenter.

Réponses (2)

Aswartha Narayana
Aswartha Narayana le 28 Nov 2011

0 votes

use str2num to convert the character string that results from get_param() into a number. The number is then suitable for use in 'if' loop.
Guy Rouleau
Guy Rouleau le 29 Nov 2011

0 votes

What you are doing (closing the file) should be done in mdlTerminate!

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by