Subplot using hold and elseif in matlab

I have a problem while subplot my graphics. Can't plot over the old graphic in object(axes) in my GUI.

The code:

if get(handles.checkerro,'Value') == 1
    plot(handles.axes4,tempo,real(Erro)','r')
    hold on
elseif get(handles.checkcalc,'Value') == 1
    plot(handles.axes4,tempo,real(Signal)')
    hold on
elseif get(handles.checksignal,'Value') == 1
    plot(handles.axes4,tempo,data)
end

checkerro, checkcalc and checksignal is ckeckboxes (GUI object)

Erro, Signal and tempo is matrices of the same size.

When I have ckeckerro and checkcalc (example) selected, can see only tempo vs real(Erro) ploted.

I await help.

thank


ANSWERS:


The flow control statements if ... elseif ... are of the type exclusive or. In pseudo code it means:

if A is true
    then A
otherwise if B is true
    then only B
end

You probably just want:

if get(handles.checkerro,'Value') == 1
    plot(handles.axes4,tempo,real(Erro)','r')
    hold on
end

if get(handles.checkcalc,'Value') == 1
    plot(handles.axes4,tempo,real(Signal)')
    hold on
end

if get(handles.checksignal,'Value') == 1
    plot(handles.axes4,tempo,data)
end


 MORE:


 ? Matlab IF and ELSEIF loop
 ? How to give value of string to another string in matlab
 ? MATLAB: if..elseif...elseif a lot of times
 ? matlab. vectorization within if/else if/else statements
 ? matlab. vectorization within if/else if/else statements
 ? matlab. vectorization within if/else if/else statements
 ? Vectorization of nested loops and if statements in MATLAB
 ? Possible Vectorization using If Statements in MATLAB
 ? Vectorize nested for-loop and if statement
 ? constructing a matrix in matlab using if, elseif and else