How can I plot before running through calculations in a function?

I have a plotting function embedded in a larger function. I would like to have the plot show up before it is finished with all the number crunching. The over all function takes a while to run and I would like to be able to check the plot to ensure all of the inputs are correct before waiting for it to finish the rest of the function. Is there any way to accomplish this?
Thanks,
-Jeremy

댓글 수: 2

I suppose you want to plot the inputs, and then allow the user to verify that the inputs look good before continuing? If so, a simple way is to insert a 'pause' command after the plotting is performed. That forces the user to press the space bar (after visually confirming the inputs are valid), before continuing.
doc pause
You could even make it more sophisticated, by allowing the user to select whether to continue with the function running, or jump out now. Something like this:
s = input('Are inputs valid (y/n)? ', 's');
if ~strcmpi(s, 'y'), %if not a 'y' answer,
return; %exit function now
end
Thanks for the advice, I ended up just having it pause for a split second to plot and then continue. That way I didn't have to do anything for it to keep working through.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

질문:

2012년 10월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by