using get_Param inside an S-function

조회 수: 2 (최근 30일)
Aswartha Narayana
Aswartha Narayana 2011년 11월 28일
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
Aswartha Narayana
Aswartha Narayana 2011년 11월 28일
using str2num did work; the output of get_param here appears to be a string.
Walter Roberson
Walter Roberson 2011년 12월 8일
There is no such thing as an if loop.

댓글을 달려면 로그인하십시오.

답변 (2개)

Aswartha Narayana
Aswartha Narayana 2011년 11월 28일
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 2011년 11월 29일
What you are doing (closing the file) should be done in mdlTerminate!

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by