How can I plot before running through calculations in a function?
4 views (last 30 days)
Show older comments
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
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
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!