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

 採用された回答

Dimuthu Dharshana Arachchige
Dimuthu Dharshana Arachchige 2020 年 7 月 2 日

0 投票

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 ExchangeModeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by