Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab Gui builder...

Status
Not open for further replies.

AQUAMAN0601

Mechanical
Joined
Jul 9, 2002
Messages
11
Location
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
 
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
 
Thanks for the tip!!

But what if i want to display the result say...in an edit text box so that the user can see the result?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top