Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Matlab Gui builder...

Status
Not open for further replies.

AQUAMAN0601

Mechanical
Jul 9, 2002
11
0
0
CA
I'm new to the GUI builder with the Matlab environment...

The question is very simple, as an examples...

If i use two edit text boxes to enter 2 variables...and a push button to execute a multiplication...

How do i display the result either in a edit text box or in a list box or any other way that will display a result on screen...

Quick reply would be appreciated...thanks
 
Replies continue below

Recommended for you

Hi,
It is very easy in the newer versions of Matlab. When you activate the GUI just answer YES to save the figure. The editor/debuger window will be opened with a prototype file. Down you will find headers for callbacks. Suppose you create 2 edit boxes , one text box (for the result) and a button. You have to fill in only acallback for the button. Under the header:
function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)

Put the following lines:

A=get(handles.edit1,'string');
B=get(handles.edit2,'string');
if ~isempty(A) & ~isempty(B)
C=num2str(str2num(A{:})*str2num(B{:}));
else
C='?';
end
set(handles.text1,'string',C)

Save the file, thats it.

Joe
BSTEX - Equation viewer for Matlab
 
Status
Not open for further replies.
Back
Top