Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to run the simulink block four times ie., for four different conditions using for loop?

조회 수: 2 (최근 30일)
Priya
Priya 2014년 8월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi,
I need to run my Simulink model for four times as I have assigned four conditions. Please find the code below.
k_A_index=[1.00 1.00 1.00 1.00];
k_S_index=[0.40 0.40 0.40 0.40];
mu_0_index=[0.55 0.30 0.06 0.03];
A_index=[0.40 0.40 0.40 0.40];
B_index=[0.60 0.20 0.20 0.10];
randomIndex = 1;
for randomIndex = 1:4
k_A = k_A_index(randomIndex);
k_A_dry=k_A
k_S = k_S_index(randomIndex);
k_S_dry=k_S
mu_0 = mu_0_index(randomIndex);
mu_0_dry=mu_0
A = A_index(randomIndex);
A_dry=A
B = B_index(randomIndex);
B_dry=B
s_x_index = 0:0.0001:0.02;
for i = 1:length(s_x_index)
x_a(i) = s_x_index(i);
epsilon_x=1/4.*[(G.*pi.*a1.*b1.*c_11.*s_x_index)/(Q.*mu)];
F=(2*Q*mu/pi).*[(k_A*epsilon_x)./(1+(k_A*epsilon_x).^2)+atan(k_S*epsilon_x)];
f_x = F/Q
f_x_save(randomIndex,:) = f_x;
end
end
%-----Run the Simulink model-----------------------------------------------
sim Single_wheelset_susp_mass_modifiedMW
x=[0,1,1,5];
y=[0,0,d,d];
figure(6);
cs = {'--b'; '-.g'; '-r'; '--.k'};
for k = 1:4
plot(t_plot,simout(:,1),cs{k});hold all;
grid on;
xlabel('Time (s)');ylabel('Wheelset lateral position (m)');
hold on;
end
hold off
legend('Dry','Wet','Low','VLow')
I have been working on this for a couple of days but couldn't get it still.Can anyone please help?
Thanks
  댓글 수: 3
Kaustubha Govind
Kaustubha Govind 2014년 8월 27일
Which of these variables are used to parameterize the Simulink model?

답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by