Change the event of one button as another is pressed in matlab app designer
8 次查看(过去 30 天)
显示 更早的评论
So, say you press a button in matlab, can it be used to change the function/event executed by a different button?
function Button1Pushed(app, event)
app.EditField.Value = "Hello"
end
% Button pushed function: InverseButton
function Button2Pushed(app, event)
app.Button1Pushed= "Goodbye" %doesn't work
end
This is what I have done so far.
0 个评论
回答(1 个)
Mohammad Sami
2021-3-15
Instead of using a fixed string value in your function. create a property in your app and use that. you can then modify its value in another function, which will change the behaviour of the other function.
% under properties section
properties (Access = private)
myvalue = "Hello"; % default value.
end
% under functions section
function Button1Pushed(app, event)
app.EditField.Value = app.myvalue;
end
% Button pushed function: InverseButton
function Button2Pushed(app, event)
app.myvalue = "Goodbye" %change the default value
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!