MATLAB: I want to modify the parameter in the matlab function block of simulink using set_param through the matlab initialization script. But it is not possible. The value is parametrized through base workspace in the form of struct. Ex: Mass.g, Mass.b

access matlab functionchange variables through script

Best Answer

This is because the Parameter uses source as the Base Workspace. Just carry out the procedure changing variable to whatever you want to, without using set_param and it would work fine. Attached is the example -
mv_sweep = Mass.m_v*(0.80:0.1:1.20);
numsims = length(mv_sweep);
for i = numsims:-1:1
in(i) = Simulink.SimulationInput(mdl);
in(i) = setVariable(in(i),'Mass.m_v',mv_sweep(i));
end
simOut =parsim(in, 'ShowProgress', 'on');
Since, I was using it for the Parallel Simulation.