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
-
Metro Technology began the year with inventory of $299,000 and purchased $1,820,000 of goods during the year. Sales for the year are $3,887,500, and Metro Technology's gross profit percentage is 60%...
-
Belsky, Weinraub, Owen, and Kelly (2001) reported on the effects of preschool childcare on the development of young children. One result suggests that children who spend more time away from their...
-
Priscilla Webster was dining at her favorite Massachusetts seafood restaurant when matters went horribly wrong. She began choking on a fishbone that had been lurking in her seafood chowder. After a...
-
Comprehensive variance analysis Kitchen Whiz manufactures premium food processors. The following is some manufacturing overhead data for Kitchen Whiz for the year ended December 31, 2010: Budgeted...
-
Does the monopoly power wielded by professional sports leagues hurt the fans, players, citizens, local economies, or the sport? What solutions could be used ?
-
Supreme Videos, Inc., produces short musical videos for sale to retail outlets. The company?s balance sheet accounts as of January 1, the beginning of its fiscal year, are given on the following...
-
1. What is a performance appraisal? Provide multiple reasons why is it beneficial for companies to give their employees a performance appraisal? List and discuss the objectives/goals of an appraisal...
-
Your company acquires another company in China. When you start to transform the organizational structure to that commonly used by your company at home and in other countries, you encounter...
-
Based on the information in the box entitled How Would You Do That? 1, assume that you have determined that established leaders have such an experience advantage that youll never catch their cost...
-
Review the opening vignette about the three bicycle manufacturers. Use the strategy-diamond and the generic strategy model to describe the positioning strategy of each firm. Based on what you know...
-
How Would You Do That? 2 applies a portfolio evaluation tool to Disney. Internally,Disney executives view one of their dynamic capabilities as that of being the best at creating world-class...
-
Try to apply the profit pool tool to another industry. Where would you turn for data to do this? How friendly is that data for the purposes of using this tool? If you are having trouble being...
-
12 (4) (a) Determine the intervals where f(x) = x5 is concave up and concave down. (b) Determine points of inflection for f.
-
Dr. Chan obtained a $15,000 demand loan at prime plus 1.5% on September 13 from the Bank of Montreal to purchase a new dental X-ray machine. Fixed payments of $700 will be deducted from the dentists...
-
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...
-
Biologists have studied the running ability of the northern quoll, a marsupial indigenous to Australia. In one set of experiments, they studied the maximum speed that quolls could run around a curved...
-
In the swing carousel amusement park ride, riders sit in chairs that are attached by a chain to a large rotating drum. As the carousel turns, the riders move in a large circle with the chains tilted...
-
The chain on a bicycle turns the rear wheel via a gear cluster, as shown in Figure Q7.6. The gears vary in size; the smallest gear has a radius of 2.3 cm, the largest a radius of 6.0 cm. If we assume...
Study smarter with the SolutionInn App