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 个评论
Matt Kindig
2012-10-25
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
2012-11-2
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!