필터 지우기
필터 지우기

What is wrong with my code? How can i set parameters from an array into a block in simulink?

조회 수: 4 (최근 30일)
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
Antonis Marinou
Antonis Marinou 2018년 2월 15일
This is a small part of my code. The 'sim_filename' is define above this code. The problem is in the function set_param i believe. Thank you

댓글을 달려면 로그인하십시오.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2018년 2월 15일
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.

카테고리

Help CenterFile Exchange에서 Author Block Masks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by