How to use this code in simulink without using For loop?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gokulraj Nattamangalathar Raju
am 19 Dez. 2023
Kommentiert: Gokulraj Nattamangalathar Raju
am 21 Dez. 2023
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
0 Kommentare
Antworten (1)
madhan ravi
am 20 Dez. 2023
Make use of Unit Delay block to use the value from previous timestep.
4 Kommentare
VBBV
am 21 Dez. 2023
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
Siehe auch
Kategorien
Mehr zu General Applications finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!