Clear Filters
Clear Filters

Problema con plot di dati, ricevo il messaggio "In workspace belonging to" e la compilazione non procede

2 views (last 30 days)
Ho scritto un codice in cui viene creata una figure tramite un plot e successivamente dentro un ciclo for vado a modificare YData del plot, prima del ciclo for ho messo waitforbuttonpress e quando la compilazione arriva a quel punto del codice nella Command Window compare: "In workspace belonging to (nome del file) ". La compilazione si ferma e non prosegue neanche cliccando sul pulsante Continue.

Answers (1)

Tushar Sharma
Tushar Sharma on 18 Mar 2024
Hi Giovanni,
It sounds like you're encountering an issue where MATLAB's execution pauses due to 'waitforbuttonpress' and doesn't resume as expected when you interact with the figure or press a button. The behaviour you are describing, particularly the execution not continuing even after pressing "Continue", is not standard and might indicate an issue with how the event is being handled or the expected function's behavior.
Some important points to consider when using 'waitforbuttonpress':
  • If a 'WindowButtonDownFcn' is defined for the figure, it executes before 'waitforbuttonpress' returns a value.
  • The 'waitforbuttonpress' function errors if the user closes the figure by clicking the window close button unless your code calls the waitforbuttonpress function within a try/catch block.
Also, To resume program execution after the 'waitforbuttonpress' function is called, a click or key press must occur in the current figure, and not just any figure. This change in behavior was introduced in order to prevent program execution from proceeding in an unintended figure. Prior to R2014b, 'waitforbuttonpress' would detect a click or key press event in any open figure. The execution stream would then resume in the figure in which the event was detected.
I hope this helps!
  3 Comments
Giovanni Testa
Giovanni Testa on 20 Mar 2024
p1=plot(X,R(1,:),'k-','LineWidth',2);
axis([xmin xmax ymin-2 ymax+2])
waitforbuttonpress
j=2;step=floor(n/100);
while j<=n
p1.YData=R(j,:);
drawnow
pause(0.01)
j=j+step;
end

Sign in to comment.

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!