How to Model For loop as Simulink Model?

Hello All,
Suppose I want to model the folowing logic or code in Simulink.
for i=1:10
A(i)=i
end
% ^ How to model the above logic
% This Example hoe to model in simulink
for i=1:10
if i==1
a(i)=24;
else
a(i)=1+i;
end
end

 採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 2 月 8 日

0 投票

Use "For Iterator Subsystem"

7 件のコメント

stozaki
stozaki 2020 年 2 月 8 日
Yes, I attached sample model.
Upendran muni
Upendran muni 2020 年 2 月 9 日
Thanks
But in the attached model i'm seeing iterator is not effective because of switch and delay block used inside the for itreator
MAtlab_question.jpg
stozaki
stozaki 2020 年 2 月 9 日
I modified it. But it is example, So please customize you to your purpose.
Upendran muni
Upendran muni 2020 年 2 月 9 日
I need a help your help,Can You model the exact model for the above problem.
stozaki
stozaki 2020 年 2 月 9 日
I attached following model.
for i=1:10
if i==1
a(i)=24;
else
a(i)=1+i;
end
end
Do you solve the problem?
Upendran muni
Upendran muni 2020 年 2 月 12 日
Woking fine
Upendran muni
Upendran muni 2020 年 2 月 12 日
for i=1:10
if i==5 % Now if its equals to 5 only then
a(i)=24;
else
a(i)=1+i;
end
end
If i ==5 only ,Then how it will work..i tried

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreate Large-Scale Model Components についてさらに検索

製品

リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by