Question

Write your answer code into one function file on matlab

 Write your answer code into one function file on matlab

 The spiral of Archimedes. The spiral of Archimedes is a curve described in polar coordinates by the equation

 r= kθ

 Where r is the distance of a point from the origin, and d is the angle of that point in radians with respect to the origin.

 Write a function file to compute the spiral of Archimedes with varying number of inputs (no input, one input, two inputs) for k, 0 and varying number of outputs (no output, one output, two outputs, which are r and

 computation time spent on computing r within [for .. end] loop). Default values of the two input arguments are: 0 ≤ θ ≤ 15π, k = 0.25.

3 0
Add a comment Improve this question Transcribed image text
Answer #1

function varargout = ArchimedesSpiral(varargin)
if isempty(varargin)
k=.025;
theta=linspace(0,15*pi,10000);
elseif length(varargin)==1
k=varargin{1};
theta=linspace(0,15*pi,10000);%2nd argument is theta
else
k=varargin{1};
theta=varargin{2};
end
tic
for i=1:length(theta)
r(i)=k*theta(i);
end
timeRequired=toc;
if nargout==1
varargout{1}=r;
elseif nargout==2
varargout{1}=r;
varargout{2}=timeRequired;
endCommand Window >> ArchimedesSpiral(.1,0:.01:2*pi) >> [r]=ArchimedesSpiral(.1,0:1:10) 0.4000 0.5000 0.6000 0.7000 0.8000 0.900

Add a comment
Know the answer?
Add Answer to:
Write your answer code into one function file on matlab
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT