How to use this code in simulink without using For loop?

1 回表示 (過去 30 日間)
Gokulraj Nattamangalathar Raju
Gokulraj Nattamangalathar Raju 2023 年 12 月 19 日
v0 = 89 / 60; % [m/s] velocity of preheating roller 4
v1 = 89.2 / 60; % [m/s] velocity of drawing roller 1
L = 0.7193; % [m] length between preheating roller 4 and drawing roller 1
t_end = 10; % [s] final time value of simulation
s0 = 0.0003537; % previous strain from preheating rollers
Dt = 0.001; % [s] step size in time
i_t = [0 : Dt : t_end]'; % [s] timeperiod required for simulation
Q_out = zeros(size(i_t)); % vector representation of amount of materials coming out
Q_in = Q_out; % vector representation of amount of materials going in
s1 = Q_out; % vector representation of strain from drawing roller 1
s1(1) = s0; % assigning strain 1 (strain from drawing roller 1) for 1st calculation as strain 0 (strain from preheating roller 4)
for k = 1:numel(i_t)-1
Q_in(k) = (v0 * Dt) / (1 + s0);
Q_out(k) = (v1 * Dt) / (1 + s1(k));
s1(k+1) = s1(k) + ((Q_out(k) - Q_in(k)) / L);
disp(s1(k))
end

回答 (1 件)

madhan ravi
madhan ravi 2023 年 12 月 20 日
Make use of Unit Delay block to use the value from previous timestep.
  4 件のコメント
VBBV
VBBV 2023 年 12 月 21 日
Q_in(k) = (v0 * Dt) / (1 + s0); % this line in the loop is constant block
The above line in the loop can be implemented as constant value i.e. constant block.
Then for the vector which uses the amount of material output and strain from drawing roller 1,
  • use two signal blocks separately in same sequence
  • use the summer block before the above two signal blocks
  • use the Unit Delay block after the above two signal blocks
  • connect the output from Unit Delay to the summer before the above two signal blocks to create a feedback
Note: Set the simulation interval time according to the time length specified in the unit delay block
Hope this helps
Gokulraj Nattamangalathar Raju
Gokulraj Nattamangalathar Raju 2023 年 12 月 21 日
I have attached my simulink model as screenshot. I dont know how to connect dekay block. please help me out. Thank you

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

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by