MATLAB GUI - How to Easily Share Data Between Two Separate GUIs
04 Mar 2008 Quan Quach 71 comments 7,342 views
Introduction
Oftentimes, we need to share data between two separate GUIs. This tutorial will show you how to do just that. While there are many ways to share data between two GUIs, this tutorial will present the most simple method (in our opinion). Below are two simple GUIs that were created as an example for this tutorial.
Quan’s GUI and Daniel’s GUI each take in an input. Quan’s GUI is able to extract the input from Daniel’s GUI, and vice versa. How is this accomplished? Let’s run through the example and find out.
Note: If you want to use a sub GUI to change settings parameters on a main GUI, check out this tutorial instead!


The Example
-
First, download the GUI skeletons here. Unzip the files and place them wherever you please.
-
Now, type
guideat the command prompt.
-
Choose to open the sample GUIs by clicking on “Open Existing GUI”. Click on “Browse” to locate where you saved the GUI files.

-
The two GUIs should look like this when you open them:

-
Click on the
icon on the GUI figure to bring up the accompanying .m file. -
First, lets add the following code to pushbutton1_Callback for Quan’s GUI.
danielFigureHandle = daniel; %stores the figure handle of Daniel's GUI here %stores the GUI data from Daniel's GUI here %now we can access any of the data from Daniel's GUI!!!! danielData = guidata(danielFigureHandle); %store the input text from Daniel's GUI %into the variable daniel_input daniel_input = get(danielData.editText_Daniel,'String'); %set the static text on Quan's GUI to match the %input text from Daniel's GUI set(handles.display_daniel_input,'String',daniel_input); %notice that danielData is the structure containing the data from Daniel's GUI %notice that handles is the structure containing data from Quan's GUI, %which is the local GUI (i.e., the GUI that this function is running from)
-
Second, lets add the following code to pushbutton1_Callback for Daniel’s GUI.
quanFigureHandle = quan; %stores the figure handle of Quan's GUI here %stores the GUI data from Quan's GUI here %now we can access any of the data from Quan's GUI!!!! quanData = guidata(quanFigureHandle); %store the input text from Quan's GUI %into the variable quan_input quan_input = get(quanData.editText_Quan,'String'); %set the static text on Daniel's GUI to match the %input text from Quan's GUI set(handles.display_quan_input,'String',quan_input); %notice that quanData is the structure containing the data from Quan's GUI %notice that handles is the structure containing data from Daniel's GUI, %which is the local GUI (i.e., the GUI that this function is running from)
-
And that’s it! Run the two GUIs simultaneously side by side. Enter in any input you choose for the two GUIs and test it to make sure that it does what you expect it too.
Download the Source Files
You can download the source files here.
71 Responses to “MATLAB GUI - How to Easily Share Data Between Two Separate GUIs”
Leave a Reply
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>


Thanks! Been planning to implement a GUI that has a settings menu, and the data selected in the settings menu could be used by the main GUI. I’m guessing with some tinkering, this is kinda what we need as a stepping stone
I really need this Thank you
Hi Quan, this article is exactly what I was looking for, many thanks. I see that you have had problems with your site, it seemed to be down most of yesterday. Today I cannot download the source files
Can you please help.
Hi Robert,
Yeah we had some trouble with our host today and yesterday. Caused some of our files to dissapear and what not. But I restored the files, they should be working again!
Thanks for the support.
Quan
Hi Quan, downloaded fine. Thanks for the help.
I have another query, a stats routine runs generating data for 2 different time periods, when I plot the data to the gui which has 2 axes I have to run the code twice, I would have liked to pass the data and axes as a parameter to the plot function. Would you be interested to look at the code and comment ?
Hai… thank you very much for the tutorial,,
I want to ask something,, what if I want to share not just the data, like if I want to have two GUI appear continously.
Like from the first GUI, we press “next” button and then the second GUI appear.
How can I do that?
Thank you very much,,
hai plz answer the above pradipta’s question….Even i want to use that badly
Let’s say I have two GUIs named gui1 and gui2.
On gui1, I have a button called next.
When I press next, in order to make gui2 appear, all I have to do is the following:
Under the callback code of the “next” button, i would simply write
Note: The m-file and fig-file for gui2 has to be in the same directory as gui1 for this to work.
Thank very much for the reply Quan..
I hope I can give you more inputs in the future, or perhaps I can give you an answer someday.. hehe
Hi, thanks for the article, this is exactly what I was looking for in a program I’m currently writing. The helpfulness of your tutorials makes me want to almost write my own. If only there was time. Thanks for the tutorials.
Oh, and on the getting custom files to work. If you add the paths you are working on to your matlab path list in preferences, they don’t have to be in the same folder.
Thanks for the tip Jim! I’m not quite the matlab guru yet, as I learn about new things all the time from our readers.
Hi Quan,this example has lead me to think a bit and now I am confused as usual. how would you go about storing a set of strings i.e. a list of files in a listbox (that u have added) and then store these in a string such as in a drop down menu that has already been defined eg a, b ,c. So I guess my questions is, how can I store the set of files in the string ‘a’ for example?
Hi froggy,
So lets say you have three files: fileA, fileB, and fileC.
If I want to display these filenames onto the popupmenu, here’s what I would do:
Hi Quan, How would you update the data variable if the files came from a listbox? is this where the get and set commands come into it?
eg data = get(handles.listbox ‘Value’) ?……….
Thanks
Yes, that should do the trick. Give it a try and let me know how it goes
Hi Quan,
I have seen all of your excellent example for GUI. I have a question which waste my time too long. in my program i need to press in the pushbutton in main GUI and then it must be open another GUI window, how can I do that?
Cheers
Saeed
Can i do that just with one m file?
Hey Saeed
All you have to do is to put the 2nd GUI name in your pushbutton function. To start your first GUI named ‘myGUI’ you just type myGUI in your command window. Similary to call any other GUI through pushbuttons, you just type the GUI name in the pushbutton function.
Can i do that just with one m file?
you will have to write your own GUI m file and not use the Matlab generated one. But since you already made 2 GUIs through matlab, its easy to keep track which m file controls which one.
Hi,
That is great Daniel,
Thank you,
Sir,
Am doing a miniproject on “matching faces of camera image and documented image”..
I dunno how to use a variable that has a resultant output of cropped image in another m-file when am working in gui..
Am using 2 variable like this in another gui form..But dunno how to proceed..plz sir help me in finding out this…
thanks…
selvi.R
Sir,
Another doubt.. Am using a msgbox just to display tat “image is equal”..after it gets displayed am trying to close it..instead an infinite scripts are running behind..added tat msgbox ix not closing…any way is there to rectify it..plz sir find a solution for this too..
thanks..
selvi.R
Hi there,
If I have created a pushbutton to link one gui to another, what do I write to get the gui I’m in to close when I press the button to open the other gui?
I too am looking for an answer to Jaml’s question. I’m creating a series of GUIs that are going to be separate items in a test/game. I would like it so that once the person pushes the button (the return key, in this case) they receive feedback (e.g. ‘That is right!’ or ‘Try again’ - I have this part completed already) and then a very short delay, followed by the next item appearing rather seamlessly, and the first screen closing. Again, I would like it to appear as though all of the items were a part of one file.
I’ve managed to make it open a second window, but can’t get the first to close. Do you suppose I’m going about this in the right way?
Peter
To get the first gui window to close automatically when the next window is opened, make a global variable (i’ve chosen windowcontrol for this example) beforehand and in the callback of the “next” button include the following :
windowcontrol=get(gcf, ‘Position’),closereq,next_gui_name
To get the next window at the exact position as the first window, include this in the .m file of the 2nd window, just after the end of initialization code:
set(gcf, ‘Position’, windowcontrol)
Thats it…
And don’t forget to declare the variable as global in the 2nd window .m file…
global windowcontrol
set(gcf, ‘Position’, windowcontrol)
Hi there everyone,
My main gui opens another smaller gui. This new gui requires handles information from the first. Using the above method the new gui is able to access exactly what it needs. When I return to the orignal gui after closing down the new one however, all of the guidata seems to have been lost. I have easily got round the problem by saving the information I need in a .mat file and opening it in the new gui, but I was wondering what the reason for this might be, and if there is a solution? I’m sure there is, but I can’t seem to work it out! Thanks a lot,
Phil
Hi Quan
First of all thank you to solve me such problem I had lived with for a lot of time.
My problem is that the second GUI opens and then the first one reappears again shadowing the second one. It happens because the statement
data = guidata (firstGUIname)
in the second GUI, further than correctly assigning the data structure of the first GUI to the variable data in the second GUI, reopens the first one (or at list it makes the first one reappear ON the second one).
At this point the statement
set(0,’CurrentFigure’,secondGUIname)
that I thought it had been worked, it doesn’t work and a looping change between the two GUI starts …:-((
How to resolve it?
Thank you
Seamone
Hi Quan,
Really helpful posts..amazing
Have you used the function ‘patch’ in matlab ?
i am facing a problem while using patch with timer.
an extra window opens up.
In this am trying to change the color of a patch object on an axes on my figure window while i press the pushbutton ‘Play’. the axes is axes_draw.
function pushbutton_Play_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_Play (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
l_strButtonLabel = get(handles.pushbutton_Play, ‘String’);
if (strcmp(l_strButtonLabel, ‘Play’) == 1)
set(handles.pushbutton_Play, ‘String’, ‘Pause’);
handles = Draw(handles);
set(handles.Timer, ‘Period’, 1 );
set(handles.Timer, ‘ExecutionMode’, ‘fixedRate’);
set(handles.Timer, ‘BusyMode’, ‘drop’);
set(handles.Timer, ‘TimerFcn’, {@TimerCallback, hObject});
set(handles.Timer, ‘StartFcn’, {@TimerCallback, hObject});
guidata(hObject, handles);
start(handles.Timer);
else
set(handles.pushbutton_Play, ‘String’, ‘Play’);
end
% Timer Call back
function TimerCallback(obj, event, hObject)
% Get the latest Handles
handles = guidata(hObject);
if (isequal(handles.tcolor, [1 1 1;0.7 0.7 0.7]))
handles.tcolor = [0.5 1 0.75; 0.75 0.33 0.69];
else
handles.tcolor = [0.75 0.33 0.69; 0.5 1 0.75];
end
l_strButtonString = get(handles.pushbutton_Play, ‘String’);
if (strcmp(l_strButtonString, ‘Pause’))
handles = Draw(handles);
end
% Very Important to Update it Back
handles.output = hObject;
guidata(hObject,handles);
where my Draw function is :
function handles = Draw(handles)
handles.vert = [0 1 1; 0 2 1; 1 2 1;1 1 1];
handles.fac = [1 2 3; 1 3 4];
cla(handles.axes_draw);
p = patch(’Faces’, handles.fac, ‘Vertices’, handles.vert, ‘FaceVertexCData’, handles.tcolor,…
‘FaceColor’, ‘flat’);
set(p, ‘Parent’, handles.axes_draw);
drawnow;
please help me with this…
thanks in advance..
Regards,
Sharina
hi
i’m new to matlab and am trying to build a gui to calculate an expression(sinx) with taylor .
I build a first gui to receive (the variable and the expression) and call the second gui which is the Taylor function.
Fom there i could collect the expression and the variable but could not make the taylor calculation
expression=get(gui1handles.collectexpression,’string’)
var=get(cgui1handles.collectvariable,’string’);
syms var ;
t=taylor(expression,3)% 3 for the order
it sends me an error message:
Function ‘taylor’ is not defined for values of class ‘char’.
Error in ==> calculsymstaylor>valider_Callback at 197
t=taylor(expression,3)
Help welcome
hi, i have a question, can i create a button wich make apear another GUI when i click it?
This is exactly what I was looking for, except I don’t want the second GUI to appear. Do you know how I would do that.
Hi!
I have the same problem as Phil.
on 08 May 2008 at 7:48 pm 26Phil
Hi there everyone,
My main gui opens another smaller gui. This new gui requires handles information from the first. Using the above method the new gui is able to access exactly what it needs. When I return to the orignal gui after closing down the new one however, all of the guidata seems to have been lost. I have easily got round the problem by saving the information I need in a .mat file and opening it in the new gui, but I was wondering what the reason for this might be, and if there is a solution? I’m sure there is, but I can’t seem to work it out! Thanks a lot,
Phil
Hi Kristin,
I just created a simple example where I called Quan’s GUI from Daniel’s GUI. I added a button on Daniel’s GUI that opens up Quan’s GUI when pressed.
Then I copied the input from Quan’s GUI and it appeared on Daniel’s GUI. I checked the handles structure before and after Quan’s GUI is closed, and it remained the same. I’m not sure what the problem, as I wasn’t able to recreate it. Contact us through the Contact Form and I can take a quick look at your code.
Quan
Hi Quan,
Help is tutorials are much appreciated!
Arjan
this method doesn’t work if you have a “reset” button like you described in another article. i’m talking about the reset button that allows multiple instances of the GUI to run simultaneously. my GUI at the moment is very complex and “hard-coded” reset button method is just not feasable. i think the problem here is the line:
quanFigureHandle = quan; %stores the figure handle of Quan’s GUI here
this opens up another instance of quan. is there a way to share data and have a multiple instances reset button?
I have a problem with your code, similar to Phil’s. My problem is as follows :
I have one gui, which is the main one. It is used to measure things from an oscilloscope. The thing is, I have to be able to define some settings, depending on the probes I use. So the idea was to add a menu (thx for your turorial about that btw ;-)) that calls a new gui, ’settings’.
Obviously, the data from the main gui have to be able to be edited by the settings-gui (change axis labels and so on). But it’s also important for the settings-gui to know some things about the current status of the main gui, there eg is a handles.language string containing the current language. Of course I want the settings-gui to have the same language as the main one, etc.
For testing, I tried to change the text in a static textbox of the main gui to ‘test’. It worked, except for the fact that it doesn’t leave the currently opened main gui, but closes it and opens a new one, with eg the default language. My code looks like this :
In the main gui (called ODDgui), to open the settings-gui :
In the settings-gui, to (try to) change the title of the main gui :
Another connected question : I used it first in the opening function of the settings-gui, to be able to set the language of the settings-gui to the same one as the main one, so at first I thought that was the problem. Is it possible to load the data from the main gui in the opening function already ?
Thx a lot in advance (and also for the other demos, I’ve never used matlabgui’s before and a lot of your demos helped me a great deal !)
Pieter
Pieter,
So I played around with the GUIs, and not sure what the problem is. I pretty much did exactly what you have, but cannot find out what your problem. Maybe you have some variables misnamed or something?
One thing you should do is to remenber to put the following line of code at the end of your callbacks:
And yes, using the opening function to load in the default settings is a good way to set the langauge of the settings gui. If you have any more questions, contact us through the contact form!
Quan
Phil,
The reason the handles isn’t updating it is because you’re trying to update the handles from the function space of the main GUI. Thus, the data updates aren’t occurring over in the main GUI. The method you used works out with the .mat file, but there is probably a better way to implement it in the code.
For instance, you can disable all buttons in the main gui when the sub gui is called.Once the sub gui is closed, it returns all the relevant values back to the main gui. Once you’re back inside the function workspace of the main gui, you can save all these relevant values. A useful command could be “uiwait” and “uiresume”. It’s basically a matter of figuring out how to return data to the main gui once the sub gui is closed. I’ll let you guys know when I come up with something!
Quan
Hi,
I’m having pretty much all the problems described above: I have 2 GUIs, the ‘main’ calls the ’settings’, and this one gets data from the first one.
I even managed to get the changes back to the main one, but…
1) first time it works. 2nd time I called the ’settings’ all the values where lost and back to default values.
2) I whent back to the main GUI properties and allowed to have more than 1 instance of the app… the program is creating a new ‘main’ GUI each time I call the ’settings’ one. When I close the settings it is updating the data in the ‘new main’ - not the original ‘main’, and keeps doing this each time I call ’settings’.
3) the ‘new main’ is created when ’settings’ reads data from the ‘main’…
handles.MainFigureHandle = P026_GUI001;… being P026_GUI001 the name of the ‘main’ GUI.
4) since the ‘new main’ is cretaed after the ’settings’, it is in the front hidding the ’settings’ one.
Any help will be very appreciated.
Paulo
Hi Paulo (and to anyone else who has had problems)
I will post an updated tutorial on creating a sub gui to store settings and what not. Hopefully I can get it done in the next couple of days so check back often. If you need help now, feel free to contact me through the contact form.
Quan
[...] main GUI, saving precious GUI space. There has been a lot of confusion in the tutorial i presented here about sharing data between two GUIs. Hopefully this will clear things [...]
Hi,
Thanks !.. really useful one ..
My requirement is, on running a m-file 2 GUIs should get opened.
One GUI should keep on looking for inputs from another GUI. On getting input from second GUI, first GUI should run functions corresponding to the inputs and plot the result.
Passing of data from one GUI to another GUI should happen automatically without pressing button or without any effort of user.
How do i do this ??? Your help would be greatly appreciated.
Ashwini
Hi Quan and everyone,
I am so glad that I found this website and thanks to the moderators and everyone else that contributes. Quan I have a question that you might be able to help me with. I am using matlab guide and building this gui with multiple sub gui windows. The user selects many buttons and some list boxes are loaded with variables but I want to add the functionality of clearing every thing and basically starting fresh without closing the app. Can you help me with how I would go forward doing this? Thank you very much
Hey HJ,
It looks like you want to implement a “reset” button. THere’s no easy way to do it, but check out the following posts:
http://blinkdagger.com/matlab/matlab-gui-creating-a-reset-button
http://blinkdagger.com/matlab/matlab-gui-creating-a-reset-button-part-ii
Quan
Hi everyone
I want to add a picture to my gui ,anyone know how to do this?
thanx alot.
Hello
I want to share variables between two GUIs.
for example, i have a variable called y in a certain callback in gui1 and i would like to use y in another call bak in gui2.
what exactly should i write in the callback of gui2?
thanks
Boaz
Hi,
Thanks for all the tutorials they are all really great!!!!
I don’t know if someone can help me, I’m doing an application that the main GUI generates a process and creates and image, but it should display the image in 2 different GUIs for 2 different screens. I manage to do the double image in 2 GUIs, but the problem is that, when I plot it in one gui the velocity is really nice, but when plotted in both it becomes really slow(up to 1 second per image) since it appears that the connection between the GUIS is rather slow(it appears that it kind of reopen the subgui). I want to know if its possible to make it faster, since they have to be really fast since its a type of research video game.
here is the part of the code that I change to do an example(still slow)
Thanks
David
Hi everybody!
I have a problem in sharing data between sub guis and main gui.
I have a main Gui with a Menú Editor.
Each menú is aimed to insert input parameters (e.g.: dipole position in x,y,z).
So, when I click on the menú “dipole position”, the main Gui calls a subgui that reads these values and save them.
The problem is that I’m not able to access these values from the main Gui since in the main there are not the objects xd, yd, zd - (I want just to use them in a function for computing the field) - so the commands ” set” and ” get” do not work. I think I would have to use the varargout function to pass the read input parameters as output from the sub gui to the main gui. But I don not know how it works…I hope somebody can help me!!!
I did in this way, more or less:
Subgui:
function subgui_xd_dipole_edit_Callback(hObject, eventdata, handles)
% hObject handle to subgui_xd_dipole_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
user_entry_xd=str2double(get(hObject, ‘String’))*1e-2;
if isnan(user_entry_xd)
errordlg(’You must enter a numeric value’, ‘Bad Input’, ‘ modal’);
end
handles.subgui_xd_dipole_edit=user_entry_xd;
%handles.xd=user_entry_xd;
guidata(hObject,handles);
and son on for y and z.
function save_dipole_pos_Callback(hObject, eventdata, handles)
% hObject handle to save_dipole_pos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mainGUIhandle = MCF_Simulator;
mainGUIdata = guidata(mainGUIhandle);
(The following commands of course can not work since in the main gui I don’t have the objects xd,yd,zd):
set(num2str(mainGUIdata.xd,’String’), get(num2str (handles.subgui_xd_dipole_edit, ‘String’)));
set(num2str(mainGUIdata.yd,’String’), get(num2str(handles.subgui_yd_dipole_edit, ‘String’)));
set(num2str(mainGUIdata.zd,’String’), get(num2str(handles.subgui_zd_dipole_edit, ‘String’)));
close(MCF_SubGui_dipole_pos);
Then in the MainGui I was trying to do something like:
xd = str2double(get(handles.xd));
yd = str2double(get(handles.yd));
zd = str2double(get(handles.zd));
But it does not recognize the handles of course!
I hope it is enough clear…It’s the first time I’m programming a GUI… :s
hai everybody
i have a problem with gui’s. I have 2 gui’s i want to share the variable in pushbutton call back of first gui , this same variable i want to get in 2nd gui’s push button call back function
can any body help to solve this problem.
Hi,
If the same logic is used to access data from a GUI in another function(NOT a gui function), the GUI from which we are accessing data pops up and needs to be closed again. Here’s what I mean:
I have two GUIs:
1. Main gui with a checkbox and an ‘Options’ box next to it.
2. A sub-gui which appears if i click on the ‘Options’ button.
The way it works:
The options button is disabled by default. If i check the checkbox, the options button activates. Now, inside the sub-gui, there is a default list, which can be changed if the user chooses to.
Now, consider another seperate function. This function is called from elsewhere, ie, its not related directly to the gui’s mentioned above. But this function has to access the list from the sub-gui mentioned above.
This is what i did:
Now, I’m able to perform the operations I require perfectly, thanks to your wonderful tutorial on the data sharing betweed gui’s. But now, after the whole operation, I end up with the main gui and the sub gui on the screen.
I was wondering if I should use delete(maingui)/delete(maingui_handles) and delete(subgui) /delete(subgui_handles) somewhere in the code?
Hey Sanky,
Give this a tutorial a look.
http://blinkdagger.com/matlab/matlab-gui-using-a-sub-gui-to-manage-setting-parameters
Quan
Hi
I have to use my main GUI to load parameters from an m.file into a sub GUI (by clicking on new parameters from menu bar) and each parameter has to go into a specific edit_text box. I was wondering if someone could help me with that. thanks in advance
@ moe
Have a look at this, this should do
http://blinkdagger.com/matlab/matlab-gui-using-a-sub-gui-to-manage-setting-parameters
hi
% — Executes on button press in test_pushbutton.
function test_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to test_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[x,y,macrocell,SSx,Cells,dm,BS_radio_1, BS_radio_2, BS_radio_3,A] = uesimulator(x,y);
i have a push button in which i am executing another function shown above called uesimulator. Now this is not written in the gui mfile.
Then i want the output variables of this function to be used within another pushbutton so as to be used in another function.
any help on how i can bypass the variables between the functions. i tried using global but it is not working.
Thanks in advance
Hi..
Thanx for great examples, I have a very important question.
I am using “patch” command to visualize a cube, but this function draws outside my gui.
how can i plot using “patch” in an axis in my GUI?
Thanks in advance.
Hi,
I’m trying to build a gui to take in a wav file and plot it in the main gui. then theres an edit button that opens a sperate gui. how do i pass the wav file to the other gui and then back again? i’m using
[data,fs,nbits] = wavread(…)
and i’ve made data and fs global so they can be accessed throughout the main gui. But how do i let the edit gui use the same data?
I’d really appreciate your help. i’m really stuck
Thanks
Hi Penny,
This tutorial holds the answers you are looking for I think:
http://blinkdagger.com/matlab/matlab-gui-using-a-sub-gui-to-manage-setting-parameters
Thanks for replying so quickly.
I understand that tutorial but as the user isnt inputing anything i don’t know what it is i should be setting in the other gui.
Hi Penny,
Pay special attention to step 9 of that tutorial. It shows you how to move data back and forth between two GUIs.
The difference between that tutorial and this one is that in this tutorial, it is assumed that both GUIs remain opened, while the other tutorial assumes that the sub GUI closes and opens depending on when the user wants to change settings, which makes it a tad more complicated.
Quan
Hey guys,
Thanks for the tutorial, but it seems when I attempt to do this I get the following error
??? Attempt to reference field of non-structure array.
Error in ==> quan>pushbutton1_Callback at 101
set(handles.display_daniel_input,’String’,daniel_input);
I even tried to run the source with no luck…
I am running MATLAB 2007b, do you need an extra toolbox or something to get set to work?
hi Quan Quach.,
I am tring to call GUI from script file…i waorks..but how can i return values which is stored in handles i.e. which user has input ,from GUI .m file back to my main script file?? thanks in advance…i learned lot about GUI from your tutorials and these are very helpful….thanks in advance
hi Quan
I am trying to access the variables in the excel file, opened using File->Open(FileOpen_callback), in another callback. Pls tell me how to do this.
hello,
i am new to MATLAB GUI. i need to work with multiple GUI’s.
problem is i have gui1 in which on clickin a push button .m file runs and the output is received in variable a. Now i want to display this output on a static text on gui2.
how to do to that?
plz reply soon, it needs to be done today.thanks alot
hiii sara
you can use this command for ur required task
set(handles.answer_staticText,’String’,c);
instead of the “answer” use the tag of the static text in which u required to have the output
“c ” would be the output
but before tht u hav to switch to the next gui (not sure enough , see the tutorial given at the top of this page)
hope it might provide u some help
hii quan and everyone
i m working on a code tht works on the iterative process and the final ans is printed on the gui.
now suppose after running a code once, i run it once more and now i want that the result of the previous run should be saved and be shown on the same gui along with the new result so that one can compare them easily
please help me
i tried many things but culdn’t get the ans
my work has stopped at this point and i am not able to come up with an alternative solution.
Anuj ,
What you need to do is look into implementing the guidata function as a method for storing the previous iterations data into a handles storage sub structure. Take a look at the sample code below and see how I have create a handles.previous_data structure to store the previous data from each run that will update each time I press the button.
Thanks Quan for these excellent tutorials! They’re really helpful on getting me started!!! I do have a question though. What if I dont want to exchange data between two specific GUIs’ and instead want to pass data back to the main GUI which called the sub GUI. The reason I’m asking this is because I have some GUIs’ which are common to a number of main GUIs’ and want to avoid using global variables.
There is a tutorial included in Matlab R2008b, but I can’t make any sense of it.
Hi every one, really cool tutorial, I learn GUI with these :p
Just a question I need to share Data between 2 GUI, the problem:
I need to intialise the data when the program start so I put the initialisation inside openingFct,
and when the data is modified by others GUI I need to do GUIdata to save and then it reinitialise the data so I loose the modification from others GUI…
Have you an idea???
I don’t know if I’m clear enough…
Thank you
totoysawa
hi all,
the tutorials are extremely helping….but i want your help on this problem…i have a gui and when i push a push button it calls a simulink program and runs it. Now i want to show 4 or 5 figures on the gui window but it does not have this much space…so i can do two things…or u guys can help in 2 ways..
1) if i can increase the size of gui window so that it can be scrolled and more figures can be put into it. how to achieve this??
2) i can call another gui from the same puch button and then the remaining figures can be seen in that gui. For that the output of the model is to be fed in this another gui. How to do that??
Hello there,
Is it possible to combine the codes of both gui’s into one m file?
cheers
That’s just awesome. Keep doing these great tutorials!