How can I set Values to Simulink Block from my Workspace?

조회 수: 19 (최근 30일)
Bob
Bob 2016년 2월 3일
댓글: Bob 2016년 2월 8일
I want to send PID Values to Simulink Model from my file.m
I have tried this way but I got an error which I dont understand what it means...
PID_Values = set_param('Simulink_Model/PID Controller','PID Controller','1','1','1');
ERROR: PID 1dof block (mask) does not have a parameter named 'PID Controller'
or
P_Value = set_param('Simulink_Model/PID Controller','PID Controller','1');
I_Value = set_param('Simulink_Model/PID Controller','PID Controller','1');
D_Value = set_param('Simulink_Model/PID Controller','PID Controller','1');
ERROR: PID 1dof block (mask) does not have a parameter named 'PID Controller'

채택된 답변

Nobel Mondal
Nobel Mondal 2016년 2월 8일
To get the list of parameters associated with 'PID Controller' block, I would use the below command :
allParams = get_param('Simulink_Model/PID Controller', 'DialogParameters');
If you are looking to find any particular parameter value, let's say the Proportional Gain :
P_Gain_Val = get_param('Simulink_Model/PID Controller', 'P');
For setting values , (P = 10, I = 2, D = 0.1)
set_param('Simulink_Model/PID Controller', 'P', '10', 'I', '2', 'D', '0.1'); % No output argument

추가 답변 (1개)

Suresh Garimella
Suresh Garimella 2016년 2월 3일
error is saying that the specific block you are using does not have parameter 'PID Controller'.
select the block, then type get_param in command window,
all parameters of that block (object) will be displayed, now use set_param to change any parameter value
  댓글 수: 2
Bob
Bob 2016년 2월 4일
P_Value_get = get_param('Simulink_Model/PID Controller','PID Controller','P');
I_Value_get = get_param('Simulink_Model/PID Controller','PID Controller','I');
D_Value_get = get_param('Simulink_Model/PID Controller','PID Controller','D');
P=10;
I=100;
D=1000;
P_Value_Set = set_param('Simulink_Model/PID Controller','PID Controller','P');
I_Value_Set = set_param('Simulink_Model/PID Controller','PID Controller','I');
D_Value_Set = set_param('Simulink_Model/PID Controller','PID Controller','D');
Again error
Nobel Mondal
Nobel Mondal 2016년 2월 8일
You are not using get_param and set_param in a proper way. Please type
help get_param
help set_param
in matlab command prompt to see the intended usage.

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

카테고리

Help CenterFile Exchange에서 Multicore Processor Targets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by