채택된 답변

Walter Roberson
Walter Roberson 2015년 11월 3일

0 개 추천

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일
thank you sir i have another question i have a gui with 2 edit text and a program p, i want to get value from first edit text and put it in variable in p . and i want to get value from variable in p and put it in the second edit text. how i do that?
marwa marwan
marwa marwan 2015년 11월 3일
i forget to say this operation done when press a push button
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개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2015년 11월 3일

댓글:

2015년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by