Thread Subject: Load data from workspace to gui

Subject: Load data from workspace to gui

From: Eli Chmouni

Date: 30 Jun, 2009 17:32:01

Message: 1 of 5

Hello everyone;
i have created a gui that loads a .mat file and thus save all the variables in the matlab workspace. My second task now is i have 2 edit text boxes and a push button
--->what i want to happen is the user of the gui can enter the name of a variable already existing in the workspace and then click the push button and the value of the variable should appear in the second edit text box (that could be a static text box too)
any help would be appreciated
Thank you

Subject: Load data from workspace to gui

From: Ilya Rozenfeld

Date: 30 Jun, 2009 20:21:01

Message: 2 of 5

Let 'var' contain the name of the variable you want to be displayed and 'boxHndl' contain handle to the edit box where you want variable to appear

In the Callback to the button do the following:

% create box handle variable in the base workspace
assignin('base', 'dispBoxHndl, boxHndl)

% assign variable value to the box
evalin('base', ['set(boxHndl, ''String'', num2str(' var '))'])

"Eli Chmouni" <echmouni@gmail.com> wrote in message <h2di6h$8ca$1@fred.mathworks.com>...
> Hello everyone;
> i have created a gui that loads a .mat file and thus save all the variables in the matlab workspace. My second task now is i have 2 edit text boxes and a push button
> --->what i want to happen is the user of the gui can enter the name of a variable already existing in the workspace and then click the push button and the value of the variable should appear in the second edit text box (that could be a static text box too)
> any help would be appreciated
> Thank you

Subject: Load data from workspace to gui

From: Giacomo

Date: 30 Jul, 2009 07:36:01

Message: 3 of 5

"Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu> wrote in message <h2ds3d$9f6$1@fred.mathworks.com>...
> Let 'var' contain the name of the variable you want to be displayed and 'boxHndl' contain handle to the edit box where you want variable to appear
>
> In the Callback to the button do the following:
>
> % create box handle variable in the base workspace
> assignin('base', 'dispBoxHndl, boxHndl)
>
> % assign variable value to the box
> evalin('base', ['set(boxHndl, ''String'', num2str(' var '))'])
>
> "Eli Chmouni" <echmouni@gmail.com> wrote in message <h2di6h$8ca$1@fred.mathworks.com>...
> > Hello everyone;
> > i have created a gui that loads a .mat file and thus save all the variables in the matlab workspace. My second task now is i have 2 edit text boxes and a push button
> > --->what i want to happen is the user of the gui can enter the name of a variable already existing in the workspace and then click the push button and the value of the variable should appear in the second edit text box (that could be a static text box too)
> > any help would be appreciated
> > Thank you


Hi Ilya, so if the edit text cell where I want the variable to appear is called for example "edit13" the code on the button for display will be:
assignin('base', 'dispedit13', handles.edit13)
evalin('base', ['set(handles.edit13, ''String'', num2str(' var '))'])

Correct? Thank you

Subject: Load data from workspace to gui

From: Ilya Rozenfeld

Date: 30 Jul, 2009 13:33:03

Message: 4 of 5

It looks like I've made a mistake. The code should've been

assignin('base', 'dispBoxHndl', boxHndl)
evalin('base', ['set(dispBoxHndl, ''String'', num2str(' var '))'])

So in your case it should be like this

 assignin('base', 'dispedit13', handles.edit13)
 evalin('base', ['set(dispedit13, ''String'', num2str(' var '))'])


"Giacomo " <bigbig1982@hotmail.com> wrote in message <h4rih1$a0u$1@fred.mathworks.com>...
> "Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu> wrote in message <h2ds3d$9f6$1@fred.mathworks.com>...
> > Let 'var' contain the name of the variable you want to be displayed and 'boxHndl' contain handle to the edit box where you want variable to appear
> >
> > In the Callback to the button do the following:
> >
> > % create box handle variable in the base workspace
> > assignin('base', 'dispBoxHndl, boxHndl)
> >
> > % assign variable value to the box
> > evalin('base', ['set(boxHndl, ''String'', num2str(' var '))'])
> >
> > "Eli Chmouni" <echmouni@gmail.com> wrote in message <h2di6h$8ca$1@fred.mathworks.com>...
> > > Hello everyone;
> > > i have created a gui that loads a .mat file and thus save all the variables in the matlab workspace. My second task now is i have 2 edit text boxes and a push button
> > > --->what i want to happen is the user of the gui can enter the name of a variable already existing in the workspace and then click the push button and the value of the variable should appear in the second edit text box (that could be a static text box too)
> > > any help would be appreciated
> > > Thank you
>
>
> Hi Ilya, so if the edit text cell where I want the variable to appear is called for example "edit13" the code on the button for display will be:
> assignin('base', 'dispedit13', handles.edit13)
> evalin('base', ['set(handles.edit13, ''String'', num2str(' var '))'])
>
> Correct? Thank you

Subject: Load data from workspace to gui

From: Giacomo

Date: 30 Jul, 2009 18:02:03

Message: 5 of 5

"Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu> wrote in message <h4s7ef$ahh$1@fred.mathworks.com>...
> It looks like I've made a mistake. The code should've been
>
> assignin('base', 'dispBoxHndl', boxHndl)
> evalin('base', ['set(dispBoxHndl, ''String'', num2str(' var '))'])
>
> So in your case it should be like this
>
> assignin('base', 'dispedit13', handles.edit13)
> evalin('base', ['set(dispedit13, ''String'', num2str(' var '))'])

Thank you very much, I'll try it tomorrow! :)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui Eli Chmouni 30 Jun, 2009 13:34:02
load Eli Chmouni 30 Jun, 2009 13:34:02
matlab Eli Chmouni 30 Jun, 2009 13:34:02
variables Eli Chmouni 30 Jun, 2009 13:34:02
push button Eli Chmouni 30 Jun, 2009 13:34:02
edit text Eli Chmouni 30 Jun, 2009 13:34:02
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com