필터 지우기
필터 지우기

how to access the variable value declared in constant block using get_param command.

조회 수: 8 (최근 30일)
how to access the variable value declared in constant block using get_param command.
------------------------------------------------------------------------------
initially i declared value for a is 1 in work space.
normally i access the variable by following way,
get_param(gcb,'value')
for above command i got the following answer, ans= a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
but, i want to get the ans is 1
how to use get_param() command to access the value 'a' stored in workspace.
i attached the screen shot of that simulink model ----------------------------------------------------------------------------------

채택된 답변

stozaki
stozaki 2020년 1월 12일
Hello Ravi,
Did you solve this problem? Please try following script.
a = 1; % define the value of 'a'
blkValue = get_param(gcb,'Value'); % get the constatn value as Parameter.
value = evalin('base',blkValue); % evaluate value in the base workspace.
Regards,
stozaki
  댓글 수: 3
stozaki
stozaki 2020년 1월 12일
Hello Ravi,
If you use model workspace, please try following script.
a = 1; % define the value of 'a'
blkValue = get_param(gcb,'Value'); % get the constatn value as Parameter.
mdlWks = get_param(gcs,'ModelWorkspace'); % get model workspace object
Prm = evalin(mdlWks,blkValue); % evaluate value in the base workspace.
If you use Simulink.Parameter, Please get the property of the value that was got last.
valueOfParameter = Prm.Value;
Regards,
stozaki

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by