What is wrong with my code? How can i set parameters from an array into a block in simulink?
Show older comments
code:
s=sprintf([sim_filename '/L_%d'],Loads_new_to_Loads_old_index(i,2));
add_block('mylibmodels/Single_phase_Var_Load', s)
set_param(s,'P', act_power_of_loads(1,i));
set_param(s,'Q', react_power_of_loads(1,i));
error:
Invalid setting in SubSystem block (mask) 'L_6' for parameter 'P'
The two arrays that i want to extract from them their values to set them as parameters in the blocks, are arrays with numbers only. Thank you
3 Comments
Birdman
on 15 Feb 2018
Undefined function or variable 'sim_filename'.
Antonis Marinou
on 15 Feb 2018
Birdman
on 15 Feb 2018
Share the entire code you wrote. Everything.
Answers (1)
Fangjun Jiang
on 15 Feb 2018
2 votes
Most block parameters, even though they are numeric to the user, are strings when getting from get_param(). So when setting the parameters, you also need to provide the string.
Just run get_param() first to see what type you get and then provide the similar. Use num2str(), mat2str() if needed.
1 Comment
Antonis Marinou
on 16 Feb 2018
Categories
Find more on Vehicle Dynamics Blockset 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!