I have two GUIs namesd masir and SetOut
SetOut GUI is a sub GUI for masir(pressing a button on masir will open SetOut)
To access the data of masir in SetOut I have these 2 lines of code:
masirGUIhandle = masir;
masirGUIdata = guidata(masirGUIhandle);
but running these 2 lines will run the opening function of masir as I work in SetOut(In opening function I have set some initial values for my variables and now I don't want those initial values ,I need changed values for my variables) so I dont want the OpeningFcn of masir GUI to be runned ,I just need to have access to masir data in SetOut
What can I do to fix the problem?
Can any one help me about this answer and explain me more?
I use this easy way for data sharing between GUIs
%In the end of OpeningFcn of Main GUI
setappdata(0,'HandleMainGUI',hObject);
%When you want to edit shared data you must get the handle
HandleMainGUI=getappdata(0,'HandleMainGUI');
%write a local variable called MyData to SharedData, any type of data
setappdata(HandleMainGUI,'SharedData',MyData);
%get SharedData and save it to a local variable called SomeDataShared
SomeDataShared=getappdata(HandleMainGUI,'SharedData');
Don't forget to clean up the data shared in the CloseReqFcn of you main GUI
HandleMainGUI=getappdata(0,'HandleMainGUI');
rmappdata(HandleMainGUI,'MySharedData') %do rmappdata for all data shared
Remember that your GUIs might try to getappdata that doesn't exist, you should first test if it does exist
if (isappdata(0,'HandleMainGUI') & isappdata(HandleMainGUI,'MySharedData'))
%get, set or rm appdata
else
%do something else, maybe loading default values into those variables
end
Tell me more aboute which line of code should be written in MainGUI and which line should be written in SubGUI?
And tell me what does the responser mean by CloseReqFcn?
Well let me summarize how I see the problem.
You want to read the data from SetOut with out creating it? That's not possible like this as the data will be created when the window is created.
A nice and systematic way around would be doing it object oriented (see Model-View Controller Pattern) You can more or less copy an example from my answer here (Example for Event - Observer)
But if you'd like to stick with your code I also have some ideas:
If you don't want the window to show you could set it invisible with set(theGUIhandle,'Visible','off')
While the window is not closed you can obtain the data with getappdata(theGUIhandle)
If you want the data after the window is closed you need to have a function that stores it outside the window.
Related
I currently have a GUI that outputs a single text file based on various input parameters. However, I need to modify my application such that the GUI outputs multiple text files based on N inputs. The original GUI designer is no longer available and the main m-file has over 5k lines of code making it difficult to troubleshoot (not to mention the code is very unorganized and not commented). Does anyone have any suggestions on how I can run the GUI N times based on the N inputs and output N text files without modifying the original m-file?
Assume your gui is called myApp and your callback to s called myButton_Callback.
I also assumng that the tag of the uicontrol is 'myButton'.
Here is the caller script:
myApp_h = myApp();
myApp_handles = guidata(myApp_h);
myButton_h = myApp_handles.myButton;
MyApp('myButton_Callback', myButton_h, myApp_handles);
You can automate any gui control by this method.
I am working on an experiment that take a lot of data samples and save it to different video files. For example, I take data and save it to a file called "slowmotion.avi" and then I take another set of data and save it to another file called "normalspeed.avi".
I am trying to find a way that I could change the name of file being saved without editing the code. The way I am using right now makes me have to open the code and change the name of the file directory within the code and then save the code. I want to make it a lot faster and easier to use.
I have tried the following code to fix this problem but it doesn't work.
graph=input('Graph of experiment: ');
vidObj = VideoWriter('%3.1f.avi\n',graph);
.....
Hope I didn't confuse you.
A possible solution:
graph=input('Graph of experiment: ','s');
vidObj = VideoWriter([graph,'.avi']);
The 's' in the input() function indicates that the expected input is a string, and [graph,'.avi'] simply concatenates both strings.
I have a GUI that displays plots, and it launches a "playlist" window. When I perform an action in the playlist window, is there a way to run a function in the launching window?
To be more clear, if I add files in the playlist window, I would like the first file in the list to be displayed in the launching window, but I would like to do this through a function in the launching window rather than passing the plot handle to the playlist window.
Thank you in advance for any assistance you can offer!
One of the easiest ways to do this, would be using findobj.
This looks through graphics objects, finding those that match the provided filter criteria.
As the number of existing figures should be relatively small, it should also be reasonably fast.
Assuming your launcher-figure has some name you can get the launcher figure-handle
e.g. via
launcherFig = findobj(0,'type','figure', 'name', <launcher-name>);
Or give your lauchner figure a Tag that you can search for:
% in your launcher-figure code:
launcherFig = figure('Tag', 'MyLauncher');
% and modify the search accordingly:
launcherFig = findobj(0, 'type', 'figure', 'Tag', 'MyLauncher');
And, for completeness, though I don't like them, you could use a global variable:
% in your launcher-figure code:
launcherFig = figure(...);
% store handle in the global variable:
global LauncherHandle;
LauncherHandle = launcherFig;
% no need for a search now anymore, just get the global variable:
global LauncherHandle
I am going through someone's data analysis files (created in an older version of matlab) and trying to find out what a particular .mat file is that was used in a matlab script.
I am trying to load a .mat file in matlab. I want to see what is in it.
When I type...
load ('file.mat')
the file loads and I see two variables appear in the workspace. jobhelp and jobs.
When I try to open jobs by typing the following in the matlab command window...
jobs
the response is..
jobs =
[1x1 struct]
Does this mean that there is only a 1 x 1 structure in the .mat file? If so, how in the world do I see what it is? I'm even happy to load it in unix, but I don't know how to do that either. Any help would be greatly appreciated as I have a few files like this that I can't get any information from.
Again, a new user, so please make it simple.
Thanks
It means that jobs is a cell array {} and within this cell array is a structure defined
To see the structure and its contents type jobs{1}
I think you are dealing with a SPM5 Batch-File. This variable is an image of the tree-like structure you can see in the Batch-Editor of SPM. Your job consists of one subitem (stats) which could have various subsubitems (like fMRI model specification, model estimation and so on).
To access this structure on the command line just proceed like Nick said:
Each level is a separate cell array that you can access with {#} after the name of the level. Example: jobs{1} shows you that there is a subitem named stats.
Subitems in structs are accessed with a dot. Example: jobes{1}.stats{1} shows you the subitems of the stats-entry.
Notice that there could be more than one entry on each layer: A stats module could (and probably would) contain various subitems. You can access them via jobs{1}.stat{2}, jobs{1}.stats{3} and so on.
The last layer would be the interesting one for you: The structures in here is an image of the options you can choose in the batch-editor.
hye everyone i m doing my project "automatic vechicle identification".i have to design software in matlab,i have done extraction of plate region ,segmentation of characters,...now i want to save these segmented characters so that i can further recognize these character from a data base......any body can help me please feel free to write to me, thanks in advance
So if you have some data, myData then you can just issue a command save myData and you will have a new file in the current directory named myData.mat. To load the data later, just type in load myData and then you will have a new variable in the workspace named myData. There's lots more you can do with this, so you should check out help save.
Alternatively you could use a database. I've never actually used a database in Matlab, but there seems to be plenty of information about how one would go about doing this: http://www.mathworks.com/help/toolbox/database/ug/database.html