I want to convert a MATLAB code into a SIMULINK MODEL. In the code, FOR LOOP is incorporated within a function block. Therefore, only one (last) output of For Loop is transferred to output. I need multiple outputs based on time interval. Can anyone help me in converting my loop into a SIMULINK Model. The code of FOR LOOP is given below;
Ts= 25e-6;
t1 =0.0000075 ;
t2 = 0.0000175;
for Tt=0:25e-8:Ts;
if (Tt <=t1)
Sa = 0;
Sb= 1;
Sc = 0;
else
Sa = 1;
Sb = 1;
Sc = 1;
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2019년 11월 11일

0 개 추천

댓글 수: 4

Muhammad Kashif Nawaz
Muhammad Kashif Nawaz 2019년 12월 3일
matlab function block has a fixed sample time (T). input and output values are updated once per one sample time. i need multiple time-based outputs. How can i update an output value more than once during one sampling interval of a matlab function block?
Walter Roberson
Walter Roberson 2019년 12월 3일
How can i update an output value more than once during one sampling interval of a matlab function block?
That is not possible.
matlab function block has a fixed sample time (T).
That is not a requirement. You can use variable step solvers with MATLAB Function Block.
Muhammad Kashif Nawaz
Muhammad Kashif Nawaz 2019년 12월 4일
Can i use pause command in For loop inside a matlab function block? i have been trying but its not working as expected
Yes you can. However, it only affects how long it takes to execute the MATLAB Function Block, nothing else about the model. You could detect that the pause() had occurred by carefully examining the real-time clock, but not by examining the clock signal (which reflects simulated time.)
For example it is valid to have a MATLAB Function block that does something like
h = msgbox('Pausing');
pause(2)
delete(h)

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2016b

질문:

2019년 11월 11일

댓글:

2019년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by