Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • 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
Jul 9, 2002
11
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
 
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