% This function will plot user-given functions over a user-prescribed % interval with different colors and a corresponding legend. % HOW TO USE: badmultiplot([m,n],'filename1','filename2',...) where m<=n % and each filename holds an algebraic function (see xquare.m and poly.m % for a template) %{ INPUT: interval - plotting interval of the form [m,n] varargin - will hold all of the function handles holding user-defined algebraic functions OUTPUT: NONE %} function badmultiplot(interval,varargin) %NOTE: varargin is something you can look up in MATLAB % none of the "varargin" lines of code is incorrect % numfuncs= the number of functions given by the user numfuncs=length(varargin); % assign a start and end to the plotting interval start=interval(0); finish=interval(1); % sets the step size for the plots step=5; %creates a color array for the different plots color=['b','k','r','g','c','m']; % sets up our x-axis x=[start:step:finish]; % creates the plot for i=1:numfuncs+1 plot(x,feval(varargin{i},x),color(1+mod(i,length(color)))); figure; end; % end on i % this prints out a legend for the plots legend(varargin);