I have the following problem:
My solution so far:Write a function m-ﬁle, PlotCircles.m, that can accept as input a vector, r,
having positive entries, and plots circles of radius r(i) on the same axis. If no input value for r is speciﬁed, the default is to plot a single circle with radius r = 1. Test your function by using r = 1:5.
Hints: Matlab commands that might be useful for this problem include max, min and any.
However when I input a vector as follows:Code:function PlotCircles(r) theta = linspace(0,2*pi,1000); if nargin == 0 r = 1; end for i = min(r):max(r) x = i*cos(theta); y = i*sin(theta); plot(x,y) axis square axis([-(r+1) (r+1) -(r+1) (r+1)]) end
And then it seems to draw only the first circle. Any help is appreciated.Code:EDU>> r = 1:5 r = 1 2 3 4 5 EDU>> PlotCircles(r) ??? Error using ==> axis>LocSetLimits at 236 Vector must have 4, 6, or 8 elements. Error in ==> axis at 96 LocSetLimits(ax(j),cur_arg); Error in ==> PlotCircles at 14 axis([-(r+1) (r+1) -(r+1) (r+1)])