i wrote GUI with 2 pop up menus

1 view (last 30 days)
abdulla ishaq
abdulla ishaq on 29 Nov 2014
Answered: Geoff Hayes on 30 Nov 2014
hello there i wrote 2 pop up menus and i'm willing to get the values in the base workspace after running the GUI
this is my script for the poop up menus
if true
% ccontent= cellstr(get(hObject,'string'));
stgrade=content(get(hObject,'value'));
if strcmp(stgrade,'S275')
ppval='S275';
else
ppval='S355';
end
assignin('base','stgrade',ppval);
Es=str2double(get(handles.Es, 'String'));
% now we have to choose between different compressive strenghts C20-C50
content2= cellstr(get(hObject,'string'));
congrade=content2(get(hObject,'value'));
if strcmp(congrade,'C20')
val='C20';
elseif strcmp(congrade,'C25')
val='C25';
elseif strcmp(congrade,'C30')
val='C30';
elseif strcmp(congrade,'C35')
val='C35';
elseif strcmp(congrade,'C40')
val='C40';
elseif strcmp(congrade,'C45')
val='C45';
elseif strcmp(congrade,'C50')
val='C50';
end
assignin('base','congrade',val);
end
now for the ppval i'm getting the value in the base workspace, but for the val it always says that Undefined function or variable "val" ... is there something wrong in my code or is it the val have a different function in MATLAB?

Answers (1)

Geoff Hayes
Geoff Hayes on 30 Nov 2014
Abdulla - I suspect that, for whatever reason, none of the conditions are being satisfied in your if/elseif code that would set val. And since you don't gave an else statement and don't initialize/define val, then the error may make sense. I suggest that you put a breakpoint at the line
congrade=content2(...);
and the run your GUI. When the debugger pauses at this line, and then step through the ode line by line. What is congrade initialized too? Do any of the conditions get satisfied so that val is initialized? Also, you may want to consider adding an else clause so that val is initialized to something.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!