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

4 views (last 30 days)
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 Comments
Matt Kindig
Matt Kindig on 25 Oct 2012
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
Jeremy
Jeremy on 2 Nov 2012
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.

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!