GUI not printing a Static text
Mostra commenti meno recenti
Hi, I have designed a GUI but there is little problem.I took some steps to ensure that there is no error during input.But the last message is not printing.
Please help
Code:
function StartButton_Callback(hObject, eventdata, handles)
% hObject handle to StartButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc
%Optimization Method Selector data
% 1=GA;2=AL;3=GS
OMS = get(get(handles.OMS,'SelectedObject'),'UserData');
%Plant Selector data
% 1=FO;2=SO;3=RP
PLSE = get(get(handles.PLSE,'SelectedObject'),'UserData');
%Delay Selector data
% 0.0;0.1;0.2;0.3
Delay = get(get(handles.Delay,'SelectedObject'),'UserData');
%Mode Selec between PI & PID
% 1 = PI & 2=PID
Mode = get(get(handles.Mode,'SelectedObject'),'UserData');
% strmax = ['Maximum = ',num2str(ymax)];
% text(xmax,ymax,strmax,'HorizontalAlignment','right');
Popsize = str2double(get(handles.Popsize,'string'));
MaxIteration = str2double(get(handles.MaxIteration,'string'));
NoOfVar = str2double(get(handles.NoOfVar,'string'));
Setpoint = str2double(get(handles.Setpoint,'string'));
ub = str2num(get(handles.ub,'string'));
lb = str2num(get(handles.ub,'string'));
if length(ub)~= length(lb)
str = 'Length of UB & LB must be same';
set(handles.Status,'String',str);
error(str);
elseif length(ub)>4
str = 'Length of UB or LB cannot be greater than 4';
set(handles.Status,'String',str);
error(str);
elseif NoOfVar~=length(ub)
str = 'Var No is not Equal to length(UB)/(LB)';
set(handles.Status,'String',str);
error(str);
elseif Mode==1 && length(ub)> 3
str = 'You must give 3 bound variable for PI';
set(handles.Status,'String',str);
error(str);
elseif Mode==2 && length(ub)~=4
str = 'You must give 4 bound variable for PI';
set(handles.Status,'String',str);
error(str);
else
str = 'No Input Error Running';
set(handles.Status,'String',str);
end
the last part is not displaying on the GUI! Help me!
else
str = 'No Input Error Running';
set(handles.Status,'String',str);
end
Risposta accettata
Più risposte (1)
Image Analyst
il 11 Apr 2017
Instead of that else, just check nargin immediately upon entering
if nargin <= 2
% Display error message
....
end
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!