MATLAB: Optionally create plots inside function

functionplot

I have a function
y=myfun(x)
y=3*x;
plot(x, y)
If x=[1 2 3 4 5]; then the plot will be plotted. Is there anyway to control if I want to make the plot or not?

Best Answer

Yes. Don't call plot() if you don't want it plotted.