I have solved with my attempt but this is running only on "Debug mode" and not in "Normal Mode"

I have a Appdesigner GUI MATLAB. I have a button, and there is a loop like this

function RUN()
t=1:0.01:3600;
for i=1:numel(t)
    y(1,i)=readValue();
    plot(t(1:i),Tco(1:i));
    pause(0.02)
end
end
function BUTTON_PRESS()
   %BREAK FROM THAT LOOP
end

I want to break this loop when I click my button

My attempt(WORKS IN DEBUG MODE BUT NOT IN NORMAL)

2nd pic: In appdesigner inside a callback to a button "PLOT AND SIM" I passed a function main_plot_function()

1st pic: shows that main_plot_function Now "STOP BUTTON " appears but clicking on that it doesn't stops loop of plotting nor it print "BUTTON!!"

enter image description here

enter image description here

But none of them worked.

1

There are 1 answers

0
Rohit gupta On BEST ANSWER

increasing the pause timer worked seamlessly to break the loop!