Separately saving time-series simulation output at each iteration

The following script calls 'Gripper3Test' Simulink model 125 times (3 'for' loops). At each time, I want to save 'trackerData1' in to the workspace output seperately. It would be great, if someone can help me in this regard. I have attached the format of the 'trackerData' varible and 'Gripper3Test' simulink model.
P1=0:1:4;
P2=0:1:4;
P3=0:1:4;
for i=1:(length(P1))
for j=1:(length(P2))
for k=1:(length(P3))
P1_in=P1(i);
P2_in=P2(j);
P3_in=P3(k);
a=sim('Gripper3Test');
b=a.get('trackerData'); %trackerDataStore is a time series data
save('Simout',b); % This doen't work.
end
end
end

 채택된 답변

This is how we can do it. Very easy. We can use num2str()
P1=0:1:4;
P2=0:1:4;
P3=0:1:4;
for i=1:(length(P1))
for j=1:(length(P2))
for k=1:(length(P3))
P1_in=P1(i);
P2_in=P2(j);
P3_in=P3(k);
sim('Gripper3Test');% This is calling the simulink model
save(['trackerDataFromWorkspace_' num2str(i) num2str(j) num2str(k)],'trackerData');
% Here trackerData is the parameter to workspace
end
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by