How do i call a pushbutton of my GUI from a MATLAB function which is integrated into a SIMULINK model ?

2 ビュー (過去 30 日間)
Chris
Chris 2016 年 5 月 6 日
編集済み: Adam 2016 年 5 月 6 日
Hi everybody !
I'm trying to control a driving Simulator from a GUI and some buttons placed on a steering wheel. The buttons have the function to turn the status of driving assistant Systems on or off. When i press a button on the GUI the callback function verifies the actual status of the driving assistant Systems based on a counter (global variable), loads a new Image(ON or OFF) into the button and raises the counter. My plan for the steering wheel button is the following: I get a signal (zero or one) in my SIMULINK model. This signal is the input of a MATLAB function which should call the GUI buttonfunction. So how do i call a pushbutton of my GUI from this function?

回答 (1 件)

Adam
Adam 2016 年 5 月 6 日
編集済み: Adam 2016 年 5 月 6 日
Note: This works fine in regular Matlab, I don't know anything about Simulink and whether there are reasons why you can't do this there.
Just factor out the function under your GUI into a different location that does not require the callback parameters, then you can call it from anywhere e.g.
function pbCallback( hObject, eventdata, handles )
calculateStuff( handles.someArg, handles.someOtherArgs )
Then calculateStuff is a function that takes relevant arguments and can be called from anywhere. You should never look to be calling a callback function explicitly from elsewhere in your code.

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by