From: Chanpreet on
dear all

I am new to matlab gui.
I have a question. please help me with your suggestions.
I want to save the option selected from pop up menu and want to use it in some other .m file.
I have used save and load comand it is also not working.
my problem looks like this
str = get(hObject,
'String');
val = get(hObject,
'Value');
% Set current data to the selected data set.
switch str{val};
case 'Inner_points'
con = 1;
case 'Inner_radius' % User selects Membrane.
con = 2;
case 'Inner_points_and_radius' % User selects Membrane.
con=3;
case 'Outer_points' % User selects Membrane.
con=4;
case 'Outer_radius' % User selects Membrane.
con=5;
case 'Outer_points_and_radius' % User selects Membrane.
con=6;
case 'Both_inner_and_outer_shape' % User selects Membrane.
con=7;
end
guidata(hObject, handles);
% save -mat con.m con
% load -mat con.m con
I want to save the con.
if you can help me with this question or if you can tell me some other option, it would be very helpful for me.
thanks in advance for looking at my problem
From: Frédéric Bergeron on
"Chanpreet " <c.kaur(a)tue.nl> wrote in message <i3oura$klh$1(a)fred.mathworks.com>...
> dear all
>
> I am new to matlab gui.
> I have a question. please help me with your suggestions.
> I want to save the option selected from pop up menu and want to use it in some other .m file.
> I have used save and load comand it is also not working.
> my problem looks like this
> str = get(hObject,
> 'String');
> val = get(hObject,
> 'Value');
> % Set current data to the selected data set.
> switch str{val};
> case 'Inner_points'
> con = 1;
> case 'Inner_radius' % User selects Membrane.
> con = 2;
> case 'Inner_points_and_radius' % User selects Membrane.
> con=3;
> case 'Outer_points' % User selects Membrane.
> con=4;
> case 'Outer_radius' % User selects Membrane.
> con=5;
> case 'Outer_points_and_radius' % User selects Membrane.
> con=6;
> case 'Both_inner_and_outer_shape' % User selects Membrane.
> con=7;
> end
> guidata(hObject, handles);
> % save -mat con.m con
> % load -mat con.m con
> I want to save the con.
> if you can help me with this question or if you can tell me some other option, it would be very helpful for me.
> thanks in advance for looking at my problem

Hey,

I suggest you not to save this info but to get it directly from your other m-file, the one that is currently loading the info. That way, no new file are created, so it's a step less to do.

To do that, you'll have to have the handle of your popupmenu. If the "other m-file" is the callback function of the popupmenu, you can use gco, but if it isn't, you'll have to save your handles at the end of your main fonction. To do that, I suggest you to use a combinaison of guihandles and guidata, which are working fine for me.

Good luck!
Fred
From: Chanpreet on
hello Fred,
thank you very much for your suggestion.
i have used handles for the pop up menu, but the problem is that when i am calling the con value i am not getting it. either i am not using it in the right way or there is some other problem.
if you can elaborate it more for me . it would be great
From: ImageAnalyst on
Try just using the value of the selected index in the switch/case
statement. Or maybe try using strcmpi() or findstr() or strfind() in
your case statements instead of testing the string value directly.
 | 
Pages: 1
Prev: input
Next: imresize function