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.
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;
end![Command 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](http://img.homeworklib.com/questions/f2b8e580-c9a4-11eb-b6ec-973a04904f55.png?x-oss-process=image/resize,w_560)
1. in Matlab, write a user-defined function, with two input (r,theta) , θ expressed in degrees) and two output arguments (X,Y). The inputs are a location on a polar coordinates corresponding to Cartesian plane expressed in rectangular coordinates. The picture below describes the problem. X, Y rcos θ Some formula that you may need: x = r * cos (theta * pi/180); y r * sin(theta * pi/180); Test your code for r=7, theta=55° and present your results.
PLEASE HELP, MATLAB, answers are very appreciated need to
study
pl
2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan. Create an m-file function called "mortgage_a.m" that will serve as...
Please use matlab
cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots a circle given the coordinates of the center and the radius. For the function name and arguments use circleplot(x,y,R). The input arguments are the and y coordinates of the center and the radius. Use linspace to generte the angle from 0 to π with 100 points. (Hint: the circle equation: x+Rcos and yy-yRsin 0.) This function has no output arguments. Plot the circle using...
Create a Function file using Matlab.
function sums = estimSum (nTerms) Before we go much further, save your file and name it the exact name of the function, estimSum Inside the function file just created, write the code needed to compute partial sums 1)k+1 2k 1 k-1 and compare the output in each case to the value of by computing the remainder Rn- _Snl for each n - 20,50, 100, 1000. When calling the function in Matlab's command window for...
Write a MATLab code for a function m-file that that can take three inputs (f, y, t) and uses a while loop to examine f(x) for x = y, x = y+2t, x = y+4t, ... until a number is larger than the previous value and returns the x value for which this happens. Notes: Assume that f is decreasing at x=y but that there is a cutoff x=b > y after which f starts increasing. Assume the input for...
Please use MATLAB to solve this, thanks
7. Write a function M-file that will compute the equivalent resistance for a series or parallel combination of an arbitrary number of resistors. Your function should: accept as input an arbitrary number of resistor values, stored in a vector ask the user to input 'p' if the resistors are in parallel; ask the user to input 's' if the resistors are in series; output the equivalent resistance for the series or parallel combination...
Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...
for r = 5 + 5cosθ A. Graph the polar function. B. Find two polar points that fit your function. (Pick an angle for θ, plug it into your function, and calculate the value of r. Write your answer in the polar coordinates form (r, θ). Repeat for a second point.) C. Find the Cartesian equivalents (x,y) for the two polar points you found in part B. (Use the conversion formulas x = rcosθ and y = rsinθ for converting...
Matlab: Write an ‘m’ file that implements a function to calculate the energy of the signal.(Hint: input time step and the sample point vectors, output the resulting energy.)
1. Write a MATLAB function in a separate file and name it mat_function, this function should accept the matrix mat_in as its first input and the real number num_in as the second input, and return the following three outputs: I. Replace each element in mat_in that is greater than num_in by 1 and each element that is less than num_in by zero to get the new matrix mat1_out. II. Replace the diagonal of mat1_out by the diagonal of mat_in while...