How to use this code in simulink without using For loop?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
madhan ravi
2023년 12월 20일
Make use of Unit Delay block to use the value from previous timestep.
댓글 수: 4
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
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!