MATLAB: How to access the variable value declared in constant block using get_param command.

get_paramscriptsimulink

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 ———————————————————————————-

Best Answer

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