Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do in MATLAB, 2. Prepare a function m-file containing a function that prints a ine (to the command window), where the line consists of

Please do in MATLAB,

image text in transcribed

2. Prepare a function m-file containing a function that prints a ine (to the command window), where the line consists of a string and the values of the elements in a vector. All these components should print on one line with white space between the different components. The input will be a structure. The first field will contain the string. The second field will contain the vector of length 4 and of class double. There will be no output variables In the third section of your script m-file, generate a structure array having 2 component structures. You can use any values you want(For example, the first field name' as string and the second field 'score' as a vector) . You will call your function twice. The first time, you will use the first component structure as input. The second time, you will use the second component structure as input.(5pts) or example. a = struct ( ' name ' , { ' Abe ' , ' Brett' } , ' scores ' , { 0: 3, 1 : 4 } ) your structure Abe 0.0 1.0 2.0 3.0 Brett 1.0 2.0 3.0 4.0 % Print after running your function 3. Prepare a function m-file containing a function that converts polar coordinates in two- dimensional space to rectangular (Cartesian) coordinates. Include a suitable H1 line and some additional comment lines. The input will be 2 vectors, and the output will be 2 vectors. The length of each vector (on input and on output) will equal the number of points whose conversion from polar to rectangular coordinates is required. (10pts) The radius of a point will appear as an element in the first input vector, and the angle (in radians) of that point will appear as the corresponding element in the second input vector The first output vector will contain the horizontal (x) coordinates, and the second output vector will contain the vertical (y) coordinates. In the first section of your script m-file (the file that you will publish), generate 2 input vectors that you will use to test your function. Use at least 5 points, with any values you want. (Each input vector should be of length 5 or greater.) Then call your function to do the coordinate conversions. Finally, print a table. Each row in the table will correspond to one point. The first 2 columns (of 4 columns in the table) should contain the original polar coordinates, and the last 2 columns should contain the equivalent rectangular coordinates Use formatted printing. The decimal points in each column should all lie on one vertical line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions