Change constant block value using push button

Hello everyone)
I want to change the value of constant block in Simulink from 0 to 1 and vice versa using push button in GUI.
function pushbutton2_Callback(hObject, eventdata, handles)
c=1
set_param('opc/Constant','value',num2str(c))

2 个评论

Could you explain more on what is working and what is not?
Your code snippets look correct. Maybe you have to open/load the model first.
load_system('opc'); % or open_system('opc','loadonly')

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Modeling 的更多信息

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by