How does the method loadVariablesFromMATFile from Simlink.SimulationInput object work?

2 visualizaciones (últimos 30 días)
I have a Simulink model 'input_checkN1P10test1' and want to run parallel computing with various settings of parameters of this model. I want to load the parameters to the model from external .mat file. Those parameters in model are ‘Start Time’ t0, ‘Stop Time’ t1, or even ‘tspan’ show up in Simulink’s ‘If’ Block (see attached), etc.. Short Questions:
1. Is it OK to use method loadVariablesFromMATfile to load values of those parameters from external .mat file?
2. What’s the difference with loadVariablesFromMATFile method other than methords 'setModelParameter' and 'setBlockParameter'?
3. Does loadVariablesFromMATfile load variables from .mat file to model's model work space?
clear all
mdl = 'input_checkN1P10test1'; % mdl has no vars in model ws and data source
N = 10;
tset = linspace(0,1,N+1);
simin(1:N) = Simulink.SimulationInput(mdl);
load_system(mdl)
hws1 = get_param(mdl,'modelworkspace')% should be empty
for i = 1: 10
simin(i) = simin(i).loadVariablesFromMATFile('inputpars_simulink.mat');
simin(i) = simin(i).setVariable('t0',tset(i),'workspace','input_checkN1P10test1');
simin(i) = simin(i).setVariable('upars',50*ones(1,10),'workspace','input_checkN1P10test1');
simin(i) = simin(i).setVariable('vpars', 5*ones(1,10),'workspace','input_checkN1P10test1');
end
simout1 = sim(simin);%

Respuestas (0)

Categorías

Más información sobre Schedule Model Components en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by