msgbox and then do nothing.
Show older comments
Hello I am writing a GUI program, input (+)and (0), if I input (-), I want it show error box, do nothing. In my code, If I input (-) it show error box but it still run plot. How do I have to do? Thank you!
function pushbutton1_Callback(hObject, eventdata, handles)
temp = get(handles.signal,'string');
temp=strrep(temp,'+',2);
temp=strrep(temp,'0',0);
temp=strrep(temp,'-',1);
for i=1:length(temp)
if temp(i)==1
msgbox(' Only + and 0');
break;
end
end
n=200;
t=0:1/n:length(temp);
x=zeros(1,length(t));
for i=0:length(temp)-1
if temp(i+1)==2
x(i*n+1:(i+1)*n)=1;
elseif temp(i+1)==0
x(i*n+1:(i+1)*n)=0;
end
end
plot(t,x,'LineWidth',3);
axis([0 t(end) -0.1 1.1]);
grid on;
title([' Bitstream: [' num2str(bitstream1) ']']);
Accepted Answer
More Answers (0)
Categories
Find more on Grid Lines, Tick Values, and Labels 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!