MATLAB code into SIMULINK
8 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Walter Roberson
2019-11-11
You can use a clock signal as input to an if/then block.
4 个评论
Walter Roberson
2019-12-4
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!