在 Matlab 中访问 parsim 数据
Accessing parsim data in Matlab
晚上好,我可以用下面的 Matlab 代码得到建议吗?这是:
%% CLEAR ALL
close all
clear all
clc
%% LOAD MODEL AND LHC FILE
tic %start the clock
idx=1;
model = 'PG_PN_basic_rev1'; %This is the simulink file you wish to run.
load_system(model);
load 'LHC_input.mat' %Call in the file created by LHC_Final.m
LHC = (LHC1_input);
k_dc = LHC((1:5),1);
k_r = LHC((1:5),2);
a_1 = LHC((1:5),3);
b_1 = LHC((1:5),4);
Kg_PG = LHC((1:5),5);
Kg_PN = LHC((1:5),6);
for i = length(k_dc):-1:1
in(i) = Simulink.SimulationInput('PG_PN_basic_rev1');
in(i) = in(i).setVariable('k_dc',k_dc(i));
for j = length(k_r):-1:1
in(j) = in(j).setVariable('k_r',k_r(j));
for k = length(a_1):-1:1
in(k) = in(k).setVariable('a_1',a_1(k));
for l = length(b_1):-1:1
in(l) = in(l).setVariable('b_1',b_1(l));
for m = length(Kg_PG):-1:1
in(m) = in(m).setVariable('Kg_PG',Kg_PG(m));
for n = length(Kg_PN):-1:1
in(n) = in(n).setVariable('Kg_PN',Kg_PN(n));
end
end
end
end
end
end
out = parsim(in, 'ShowProgress', 'on');
% eval(['PN_batch', int2str(idx),' =PN;']);
% data = eval(['PN_batch', int2str(idx)]);
% a{idx} = data;
% idx=idx+1;
% run = idx
timeElapsed = toc %How long did you code run for?
我希望能够为每个 parsim 运行(PN_batch1、PN_batch2、...等)生成一个输出文件。但是,数据通常只包含 1 个输出,并且没有划分为可读的工作区对象,我可以稍后使用另一个脚本读取这些对象。任何建议将不胜感激。谢谢。
out
是一个长度等于模拟次数的向量,每个条目中都存储了模拟数据。如果您的模型中有 to workspace 块,您可以使用 out(10).NameOftoWorkspaceData
访问每次模拟的数据,以防您想要获取第 10 次模拟的数据。有关 out
变量的更多信息,请访问 here Mathworks 网站。
提示:运行模型并检查变量out
,然后你可以探索它的结构
晚上好,我可以用下面的 Matlab 代码得到建议吗?这是:
%% CLEAR ALL
close all
clear all
clc
%% LOAD MODEL AND LHC FILE
tic %start the clock
idx=1;
model = 'PG_PN_basic_rev1'; %This is the simulink file you wish to run.
load_system(model);
load 'LHC_input.mat' %Call in the file created by LHC_Final.m
LHC = (LHC1_input);
k_dc = LHC((1:5),1);
k_r = LHC((1:5),2);
a_1 = LHC((1:5),3);
b_1 = LHC((1:5),4);
Kg_PG = LHC((1:5),5);
Kg_PN = LHC((1:5),6);
for i = length(k_dc):-1:1
in(i) = Simulink.SimulationInput('PG_PN_basic_rev1');
in(i) = in(i).setVariable('k_dc',k_dc(i));
for j = length(k_r):-1:1
in(j) = in(j).setVariable('k_r',k_r(j));
for k = length(a_1):-1:1
in(k) = in(k).setVariable('a_1',a_1(k));
for l = length(b_1):-1:1
in(l) = in(l).setVariable('b_1',b_1(l));
for m = length(Kg_PG):-1:1
in(m) = in(m).setVariable('Kg_PG',Kg_PG(m));
for n = length(Kg_PN):-1:1
in(n) = in(n).setVariable('Kg_PN',Kg_PN(n));
end
end
end
end
end
end
out = parsim(in, 'ShowProgress', 'on');
% eval(['PN_batch', int2str(idx),' =PN;']);
% data = eval(['PN_batch', int2str(idx)]);
% a{idx} = data;
% idx=idx+1;
% run = idx
timeElapsed = toc %How long did you code run for?
我希望能够为每个 parsim 运行(PN_batch1、PN_batch2、...等)生成一个输出文件。但是,数据通常只包含 1 个输出,并且没有划分为可读的工作区对象,我可以稍后使用另一个脚本读取这些对象。任何建议将不胜感激。谢谢。
out
是一个长度等于模拟次数的向量,每个条目中都存储了模拟数据。如果您的模型中有 to workspace 块,您可以使用 out(10).NameOftoWorkspaceData
访问每次模拟的数据,以防您想要获取第 10 次模拟的数据。有关 out
变量的更多信息,请访问 here Mathworks 网站。
提示:运行模型并检查变量out
,然后你可以探索它的结构