Clear Filters
Clear Filters

Sim works fine, but parsim reports error : Unrecognized function or variable '

2 views (last 30 days)
Hello, I met a problem related to parsim.
I parameterize the value on a subsystem parameter, change the varible value at each simulation then run the simulatoin and check the influence of the output. Here is a part of my code, Init(simu_type,autoinjectorlist) is a function that I initialize the variable to 0 and then setVariable/parameters to a specific value from a table named "T_MC_type".
Everything goes well when i use out = sim(simIn), but when I use parsim, sometimes it reports: Error evaluating parameter ''Bias_value'' in ''CheckMonteCarlo/FI1''Caused by: Unrecognized function or variable ''Bias_value_FI1''. Variable ''Bias_value_FI1'' does not exist.
I don't understand why the error occures only on Parsim, each simulation I initialize the variable and give the value.
Anyone knows the reason? Any help is appreciated.
MC_idx= 0
for cc = 1:height(T_MC)
MC_idx = MC_idx+1;
simIn(MC_idx) = Simulink.SimulationInput(gcs);
for dd = 1:numel(T_MC_type.Properties.VariableNames)
set_param( autoinjectorlist{dd} ,'Fault_type' ,convertCharsToStrings(T_MC_type{cc,dd}{1}))
simIn(MC_idx) = simIn(MC_idx).setBlockParameter(autoinjectorlist{dd},'Fault_type',(T_MC_type{cc,dd}{1}));
if contains(T_MC_type{cc,dd},"Bias")
Init(simu_type,autoinjectorlist)
simIn(MC_idx) = simIn(MC_idx).setVariable(append('Bias_value_',get_param(autoinjectorlist{dd},'Name')),str2double(T_MC_value{cc,dd}));
end
if contains(T_MC_type{cc,dd},"Delay")
Init(simu_type,autoinjectorlist)
simIn(MC_idx) = simIn(MC_idx).setVariable(append('Delay_value_',get_param(autoinjectorlist{dd},'Name')),str2double(T_MC_value{cc,dd}/0.001));
end
end
if contains(T_MC_type{cc,dd},"Nominal")
Init(simu_type,autoinjectorlist)
simIn(MC_idx) = simIn(MC_idx).setBlockParameter(autoinjectorlist{dd},'Fault_type',convertCharsToStrings('Nominal'));
end
end
save_system(gcs)
out=parsim(simIn)

Answers (0)

Categories

Find more on Run Multiple Simulations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!