Task 1 Using 'if', 'elseif' and 'else' statements write a MATLAB script that takes x and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 1 Using 'if', 'elseif' and 'else' statements write a MATLAB script that takes x and y coordinates as inputs from the user and computes the angle with respect to the positive x-axis (counter-clockwise) as well as the corresponding quadrant. 1. Angle in the first quadrant when both x and y are positive. 0 = tan¯¹ | 2. Angle in second quadrant = 180° - 0 - when x is negative and y is positive. 3. Angle in third quadrant = 180° +0 - when x is negative and y is negative. 4. Angle in fourth quadrant = 360° - 0 - when x is positive and y is negative. Quadrant II 180° (-1,0) Quadrant III 90° (0, -1) Test your code for following coordinates: A. (x,y) = (5, 12) (0,1) 270° r=1 The command window should appear like the following: E.g. Enter x coordinate: -5 Enter y coordinate: -12 Required angle is 247.38 and is in the 3rd quadrant E.g. Enter x coordinate: 0 Enter y coordinate: 12 Required angle is 90 degrees and falls on the positive-y axis Quadrant I (1,0) X ➜0°, 360° Quadrant IV B. (x,y) = (0, 12) C. (x,y) = (-5, -12) D. (x,y) = (0, -12) Caution: Inputs of x=0 and y=0 should return an 'undefined' error. Task 2 The circumference of a circle is given by C = 2πr where r is the radius. The circumference of an ellipse can be approximated by E = π r [3(a + b) − √(3a + b)(a + 3b)] where a and b are the minor and major axis lengths. A. Write an m-file which prompts the user to specify whether they would like to calculate the circumference of a circle or an ellipse. If the circle option is chosen, ask the user for a radius. If the ellipse option is chosen, ask the user for the minor and major axis lengths. B. Calculate the circumference of the chosen shape. Use fprintf to write a statement containing the shape chosen, the relevant length(s) and the circumference. C. Ask the user if they would like to repeat the calculation. If yes is chosen, go through steps A and B again. If no is chosen, end the code. Hint: Use a while loop to achieve part C. Your code should look similar to the following: Enter either circle (1) or ellipse (2): 1 Enter the radius length: 1 Circle was chosen with a radius of 1. Circumference = 6.283185e+00 Would you like to repeat the calculation? 1=yes, 0=no: 1 Task 1 Using 'if', 'elseif' and 'else' statements write a MATLAB script that takes x and y coordinates as inputs from the user and computes the angle with respect to the positive x-axis (counter-clockwise) as well as the corresponding quadrant. 1. Angle in the first quadrant when both x and y are positive. 0 = tan¯¹ | 2. Angle in second quadrant = 180° - 0 - when x is negative and y is positive. 3. Angle in third quadrant = 180° +0 - when x is negative and y is negative. 4. Angle in fourth quadrant = 360° - 0 - when x is positive and y is negative. Quadrant II 180° (-1,0) Quadrant III 90° (0, -1) Test your code for following coordinates: A. (x,y) = (5, 12) (0,1) 270° r=1 The command window should appear like the following: E.g. Enter x coordinate: -5 Enter y coordinate: -12 Required angle is 247.38 and is in the 3rd quadrant E.g. Enter x coordinate: 0 Enter y coordinate: 12 Required angle is 90 degrees and falls on the positive-y axis Quadrant I (1,0) X ➜0°, 360° Quadrant IV B. (x,y) = (0, 12) C. (x,y) = (-5, -12) D. (x,y) = (0, -12) Caution: Inputs of x=0 and y=0 should return an 'undefined' error. Task 2 The circumference of a circle is given by C = 2πr where r is the radius. The circumference of an ellipse can be approximated by E = π r [3(a + b) − √(3a + b)(a + 3b)] where a and b are the minor and major axis lengths. A. Write an m-file which prompts the user to specify whether they would like to calculate the circumference of a circle or an ellipse. If the circle option is chosen, ask the user for a radius. If the ellipse option is chosen, ask the user for the minor and major axis lengths. B. Calculate the circumference of the chosen shape. Use fprintf to write a statement containing the shape chosen, the relevant length(s) and the circumference. C. Ask the user if they would like to repeat the calculation. If yes is chosen, go through steps A and B again. If no is chosen, end the code. Hint: Use a while loop to achieve part C. Your code should look similar to the following: Enter either circle (1) or ellipse (2): 1 Enter the radius length: 1 Circle was chosen with a radius of 1. Circumference = 6.283185e+00 Would you like to repeat the calculation? 1=yes, 0=no: 1
Expert Answer:
Answer rating: 100% (QA)
MATLAB Script task TASK1 sprintf sprintf sprintf promptx Enter the value x x inputpromptx prompty En... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
PLEASE ANSWER USING EXCEL FORMAT POSTED BELOW a) Determine the market value of debt b) Determine the market value of equity c) Determine the market value of preferred stock c) Determine the total...
-
Write a MATLAB script to produce plots of the speed and efficiency of the single-phase motor of Problem 9.5 as a function of output power over the range 0 < Pout < 500 W.
-
Write a MATLAB script to plot a set of per-unit power-angle curves for a salient-pole synchronous generator connected to an infinite bus (V bus = 1.0 per unit). The generator reactances are X d =...
-
Use the graphs of f and g to solve Exercises 8390. Find (fg)(2). y = g(x) HH y .y = f(x) # X
-
In Problem 13.7 on page 531, you used the number of customers to predict the waiting time on the checkout line. The data are stored in Supermarket. Use the results of that problem. a. At the 0.05...
-
Read the following case study and answer questions 1-3 based on the case study Headquartered in Billund, Denmark, the family owned LEGO Group has 12,500 employees worldwide and is the second-largest...
-
Presented below are the condensed financial statements of Global Enterprises, Inc. The companys inventory is valued using LIFO. The companys footnotes reveal that the LIFO reserve was as follows....
-
Mackenzie Corp. is preparing the December 31, 2014, year-end financial statements. Following are selected unadjusted account balances: Estimated warranty liability ....... $ 6,460 Income tax...
-
Joe is a new property manager for Capital City Apartments. He is in the process of establishing rental rates for the units. What is Joe's basic concern in setting the rates? Question 3 options: That...
-
Hooyay is a low cost manufacturer of smartphones in Myanmar. They recently listed in 2017 on the Singapore Exchange and did not issue any dividends for 2017 and have no plans to for 2018. They do...
-
Multiple Choice Questions: 1) Which of the following is a step in the preparation of a production cost report? A) Assignment of costs to units completed and units in process B) Summarization of the...
-
Is there a link between product-specific and site-specific life-cycle assessment? Which of these practical ways of drawing boundaries to the life-cycle assessment system will best help companies to...
-
What is the free-rider problem? Why does it discourage innovation in environmental protection and the adoption of high environmental standards? Can anything be done to overcome the free-rider problem?
-
For a small eco-tourism company keen to use life-cycle assessment for competitive reasons, is a streamlined life-cycle assessment, life-cycle review, matrix approach or comprehensive approach the...
-
Background inventory data represent average environmental interventions related to a particular material used in a particular industry.Who supplies such information? Why has background inventory data...
-
Environment regulations require investments in end-of-pipe technology to clean up pollutants: Explain whether you agree with this statement. Does this mean that a company should not undertake an...
-
Suppose, risk-free rate is 1.5%. The optimal tangent portfolio is formed with 30% on Amazon and 70% on Pfizer. The optimal risky portfolio has expected return of 24%, standard deviaiton of 15%, and...
-
The following table shows the rates of total return in successive years from 2004 to 2008 for the Sprott Canadian Equity Fund and for the benchmark Toronto Stock Exchange S&P/TSX Composite Index. By...
-
A 550-kW, 2400-V, six-pole, 60-Hz three-phase induction motor has the following equivalent circuit parameters in ohms-per-phase-Y referred to the stator: R1 = 0.108 R2 = 0.296 X1 = 1.18 X2 = 1.32 Xm...
-
For a 25-kW, 230-V, three-phase, 60-Hz squirrel-cage motor operating at rated voltage and frequency, the rotor I2R loss at maximum torque is 9.0 times that at full-load torque, and the slip at...
-
A dc shunt motor operating at an armature terminal voltage of 125 V is observed to be operating at a speed of 1180 r/min. When the motor is operated unloaded at the same armature terminal voltage but...
-
Bowen Corporation has the following shares outstanding: 15,000 shares of \(\$ 50\) par value, six percent preferred stock and 50,000 shares of \(\$ 5\) par value common stock. During its first three...
-
High Corporation has 60,000 shares of \(\$ 20\) par value common stock outstanding and retained earnings of \(\$ 800,000\). The company declares a 100 percent stock dividend. The market price at the...
-
Lester Corporation has 30,000 shares of \(\$ 1\) par value common stock outstanding. The company has \(\$ 250,000\) of retained earnings. At year-end, the company declares a cash dividend of \(\$...
Study smarter with the SolutionInn App