How to apply 'For Iterator" in simulink?

Recently I've been trying to simulate a model in simulink. I wanted to run the system using For Iterator, I try to express it using code.
int local_time;
for(local_time=9; local_time<=17; local_time=local_time+1)
{
a=local_time+b; //One equation using local_time as input
sin c=(cos a)*(cos b);//another 2 equation need a as input
cos d=(sin a)*(cos C);//the equation will calculate using different
//local_time from 9 to 17
}
Can it be done using Simulink 'For Iterator'? And do I need to put my equation block inside the 'For Iterator' block?

답변 (1개)

TAB
TAB 2018년 7월 17일

0 개 추천

Use For Iterator Subsystem SubSystem:
  • Set Iteration limit to 9 (for iterating 1 to 9)
  • Add inport to iterator Subsystem as b
  • Add outports to iterator Subsystem as c & d (I assume c & d are outputs)
  • Implement your logic

댓글 수: 4

Men Loon Chan
Men Loon Chan 2018년 7월 17일
편집: Men Loon Chan 2018년 7월 17일
How about the local_time=local_time+1;? How do put it into the system?
TAB
TAB 2018년 7월 17일
Not needed. For iterator will do it. You can get the iternatioin count from "For Iterator Subsystem\For Iterator" block (output N). This will act as "local_time" for you.
Men Loon Chan
Men Loon Chan 2018년 7월 17일
Thanks Tabrez, if I found any problem, can I just find you here? >.< Thanks a lot
Men Loon Chan
Men Loon Chan 2018년 7월 18일
Sorry Tabrez, is it possible to show the output value one by one? For example, if local_time = 9 then c = 10 and d = 11, when local_time = 10, c = 12 and d =14 and so on. The output value will be from local_time = 9 to 17.

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

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

제품

릴리스

R2017a

태그

질문:

2018년 7월 17일

댓글:

2018년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by