Question
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 the green color and set axis equal. Also label x and y-axis. Show the function file and the resulting figures. Use the function to plot the following circles: (a) x-35, y 2.0, R 8.5 Answer: Function circleplot.m: (b) x 4.0, y 1.5, R- 10 Command Window:
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)
function a=circleplot(xc,yc,r)

th=0:0.01:2*pi

x=xc+r*cos(th);

y=yc+r*sin(th);

plot(x,y);

end


(b)
function a=circleplot(xc,yc,r)

th=0:0.01:2*pi

x=xc+r*cos(th);

y=yc+r*sin(th);

plot(x,y);

end

Add a comment
Know the answer?
Add Answer to:
Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots...
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
  • MATLAB Problem HW7P2 (20 points) (5 pts) Write a user-defined MATLAB function called HW7P2_fn for the...

    MATLAB Problem HW7P2 (20 points) (5 pts) Write a user-defined MATLAB function called HW7P2_fn for the following math function 3 o-0.47x The input to the function is x and the output is y. Write the function such that x can be an array (use element-by-element operations) (15 pts) Use the function in (a) the command window to calculate y(-2) and y(5) (b) a script file HW7P2.m to determine y(x) for 0.001 Sx S 10 with 1000 points. Hint: Use the...

  • Question 1: Creating a user-defined function Write a user-defined MATLAB function named PBTask4pl_f.m for the following...

    Question 1: Creating a user-defined function Write a user-defined MATLAB function named PBTask4pl_f.m for the following math function with x the input argument and y the output y(x)=0.8x4-13x2-5x The function should work for x being a scalar or a vector. Write a script file named PBTask4pl.m to a) Use the function to calculate y(3) and y(5) and display the results in command window b) Use the function to make a plot of the function y(x) for -5:5: x 5:5. Label...

  • 1. in Matlab, write a user-defined function, with two input (r,theta) , θ expressed in degrees)...

    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 with this MATLAB problem! I'm writing in MATLAB_R2018b if that makes a difference:) 7....

    Please help with this MATLAB problem! I'm writing in MATLAB_R2018b if that makes a difference:) 7. Write a Matlab function (HW07 07.m) that takes 4 arguments and returns two arrays. The arguments are the Xc and yc coordinates of the center of a circle, the radius r of the circle, and the number of points n on the circle. The function should create a list of n equally-spaced angle values ranging from 0 to 2n. Then, for each angle value,...

  • Don't use fplot command. Matlab code. Write out code please, don't make it a screenshot. 2....

    Don't use fplot command. Matlab code. Write out code please, don't make it a screenshot. 2. Use the subplot command to make two plots of the function f(x) = (x + 1)(x - 2)(2x – 0.25) - et one graph for 0 < x <3 and the other for 3 < x < 6. Use a logarithmic scale for the y-axis. Include a plot title (for each subplot), and label both aris(for each subplot).

  • Write a MATLAB function cobweb that plots a cobweb diagram to visualise the iterations per- forme...

    Write a MATLAB function cobweb that plots a cobweb diagram to visualise the iterations per- formed by an iterative method of the form xn+1 = g(xn). the cobweb function should take as its inputs a function handle g of a function that implements g, an initial estimate x0, the number of iterations to perform numits, values xmin, xmax, ymin and ymax, and a one dimensional array ud. The function g may be undefined or discontinuous at a finite number of...

  • Write a user-defined MATLAB function for the following math function y(x). The input to the function...

    Write a user-defined MATLAB function for the following math function y(x). The input to the function is x and the output is y. y(x)=-(0.2*x^4)+((e^-0.5*x)*x^3)+7*x^2 Call the function to calculate y(x) over the interval -3 ≤ x ≤ 4 for each increment of 1. Display x and corresponding y(x) in a text file with labeled column headings. Use the type command to display the contents in the text file.

  • Write a user-defined MATLAB function that gives a random integer number within a range between two...

    Write a user-defined MATLAB function that gives a random integer number within a range between two numbers. For the function name and arguments, use n = randint(a,b) where the two input arguments a and b are the two numbers and the output argument n is the random number. Use the function in the command window for the following: (a) Generate a random number between 1 and 49. (b) Generate a random number between -35 and -2

  • P2) Write a MATLAB function myLinReg Username that is defined below. Use the in-built MATLAB func...

    P2) Write a MATLAB function myLinReg Username that is defined below. Use the in-built MATLAB function sum( ) to ease your programming (you are NOT allowed to use polyfit() and polyval()). Test the output of this function with the results obtained by hand for P1. Submit printout of program and a screenshot of the command window showing the results for P1. function [coeffvec, r2]-myLinReg_Username (xi,yi) %Function file: myLinReg-Username .m Purpose : 8 To obtain the parameters of a L.S. linear...

  • please solve in matlab 1[35p) Write a user-defined MATLAB function that determines the unit vector in...

    please solve in matlab 1[35p) Write a user-defined MATLAB function that determines the unit vector in the direction of the line that connects two points (A and B) in space. For the func- tion name and arguments, use n = unitvec (A,B). The input to the function are two vectors A and B, each with the Cartesian coordinates of the corre- sponding point. The output is a vector with the components of the unit vector Join the direction from A...

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