in GUI when press button will run a program

1 回表示 (過去 30 日間)
marwa marwan
marwa marwan 2015 年 11 月 3 日
コメント済み: Walter Roberson 2015 年 11 月 3 日
please in GUI i want to execute a program p.m when press push button

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 3 日
You would have a Callback property configured for the pushbutton. Code that callback to consist of the header and then the line
p;
This will cause p to be run when the button is pressed.
For example,
function pushbutton1_callback(hObject, event, handles)
p;
  3 件のコメント
marwa marwan
marwa marwan 2015 年 11 月 3 日
i forget to say this operation done when press a push button
Walter Roberson
Walter Roberson 2015 年 11 月 3 日
firstval = get(handles.editbox1, 'String');
result = p(firstval);
set(handles.editbox2, 'String', result);
That is, you would pass the value into p (which would have to be a "function") and you would have p return the desired value, which you would send where it should go.
Reminder: the contents of edit boxes are strings or sometimes cell array of strings (depending on whether they are configured as multiline or not). If the strings represent numbers then you will need to convert them to numeric form before using their numeric value:
firstval = str2double( get(handles.editbox1, 'String') );
result = p(firstval);
set(handles.editbox2, 'String', result);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by