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. Related SolutionsMATLAB: Optional Function input arguments You would use varargin,https://www.mathworks.com/help/matlab/ref/varargin.html#f77-385387function theFunction(varargin) for i=1:numel(varargin) matrix=varargin{i}; ... endend MATLAB: Help me about plot and linspace in matlab It should bex = linspace(1,10,100);y = (2./x).^3;plot(x,y,'linewidth',4,'color','r') Related QuestionTwo optional parameters mutually exclusiveSolve systems of equations graphicallyPlot ProblemLabeling Plots inside Function
Best Answer