Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
data handling in GUI

Subject: data handling in GUI

From: Alex Ter-Sarkissov

Date: 27 Sep, 2010 10:09:04

Message: 1 of 4

hi, here's the problem:

let's say I have 2 buttons. The first 1 generates, say, a KxK matrix of random numbers. The second one takes this matrix as an input variable and, say, multiplies them by 2 (just 4 example). How should I store the output of the 1st callback function, so that it can be taken as an input by the callback of the second button?

Sorry if it was a bit messy.

cheers,

Alex

Subject: data handling in GUI

From: Uwe

Date: 27 Sep, 2010 10:46:05

Message: 2 of 4

Hi Alex,

I would use the guide function to create the GUI, with automatic generation of callback functions. Then you can append your matrix to the handles structue, which is automatically input of all callback functions. Don't forget to have "guidata(hObject,handles)" at the end of each callback function.

Uwe

"Alex Ter-Sarkissov" <ater1980@gmail.com> wrote in message <i7pqg0$ih2$1@fred.mathworks.com>...
> hi, here's the problem:
>
> let's say I have 2 buttons. The first 1 generates, say, a KxK matrix of random numbers. The second one takes this matrix as an input variable and, say, multiplies them by 2 (just 4 example). How should I store the output of the 1st callback function, so that it can be taken as an input by the callback of the second button?
>
> Sorry if it was a bit messy.
>
> cheers,
>
> Alex

Subject: data handling in GUI

From: Malcolm McLean

Date: 27 Sep, 2010 11:32:04

Message: 3 of 4

"Alex Ter-Sarkissov" <ater1980@gmail.com> wrote in message <i7pqg0$ih2$1@fred.mathworks.com>...
> hi, here's the problem:
>
> let's say I have 2 buttons. The first 1 generates, say, a KxK matrix of random numbers. The second one takes this matrix as an input variable and, say, multiplies them by 2 (just 4 example). How should I store the output of the 1st callback function, so that it can be taken as an input by the callback of the second button?
>
> Sorry if it was a bit messy.
>
Callbacks can be local to the function that creates the button. So have a "rndmtx" variable in the workspace of the main GUI function, and create the buttons. You also probably want to create a uitable object so the user can see the data.
When he presses button 1, the callback sets rndmtx to random, and updates the table. When he presses button 2, the callback sets rndmtx to rndmtx .* 2, and again updates the table.

Subject: data handling in GUI

From: Alex Ter-Sarkissov

Date: 28 Sep, 2010 07:44:04

Message: 4 of 4

I ended up using
m=rand(m,n);
set(hObject,'Userdata',m) and it worked totally fine

thanks guys

"Malcolm McLean" <malcolm.mclean5@btinternet.com> wrote in message <i7pvbk$5dd$1@fred.mathworks.com>...
> "Alex Ter-Sarkissov" <ater1980@gmail.com> wrote in message <i7pqg0$ih2$1@fred.mathworks.com>...
> > hi, here's the problem:
> >
> > let's say I have 2 buttons. The first 1 generates, say, a KxK matrix of random numbers. The second one takes this matrix as an input variable and, say, multiplies them by 2 (just 4 example). How should I store the output of the 1st callback function, so that it can be taken as an input by the callback of the second button?
> >
> > Sorry if it was a bit messy.
> >
> Callbacks can be local to the function that creates the button. So have a "rndmtx" variable in the workspace of the main GUI function, and create the buttons. You also probably want to create a uitable object so the user can see the data.
> When he presses button 1, the callback sets rndmtx to random, and updates the table. When he presses button 2, the callback sets rndmtx to rndmtx .* 2, and again updates the table.

Tags for this Thread

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.

Contact us