Speeding up Matlab-Simulink Running in a Loop

1 Ansicht (letzte 30 Tage)
ALZ
ALZ am 24 Mai 2016
Hi I have fairly large Simulink Model (however it runs fast). Now Am running the model from Matlab using SIM command and Nested For Loops, where I change variables in Simulink Model at every step.
is there anyway to speed up the simulation ?? Currently it takes 10 minutes for 780 simulations, however I want it to be more efficient.
The code am using is as following:
clear
clc
close all
X=10:15:210; % Variable 1 to be changed every run
Y=4.5:-0.15:3; % Variable 2 to be changed every run
for q=1:length(Y)
rini=Y(q); % Variable in Simulink Model
for i=1:length(X)
T_l=X(i); % Variable in Simulink
sim('Vaildated_sen.slx')
%%Post Processing Simulink Results %%%
vec1(i,:)=T1./T22; % T1,T22 are outputs From Simulink Model
vec2(i,:)=(F2./F1); % T1,T22 are outputs From Simulink Model
vec3(i)=T_l/100; % T1,T22 are outputs From Simulink Model
vec4(i,:)=r1; % T1,T22 are outputs From Simulink Model
vec5(i,:)=r1d; % T1,T22 are outputs From Simulink Model
A=vec4(i,:);
indices(i,:) = find([0 diff(sign(A))]~=0); %%Find the index of a point
d=indices(:,2);
FR_temp=vec1(:,d);
GR_temp=vec2(:,d);
%Storing Post Processed Results
TR(i)=ku(i)/t_in;
FR(q,i)=FR_temp(i);
RR(q,i)=GR_temp(i);
GG(q,i)=rini2(q)/3;
%%%Clear and start new X
clear vec1 vec2 vec3 vec4 vec5
end
end
Thank you

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by