Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pre-Lab-12 Assignment 1. Show the syntax for a Matlab function header definition

ID: 3700853 • Letter: P

Question

Pre-Lab-12 Assignment 1. Show the syntax for a Matlab function header definition line. 2. What is a global variable in the contest of the Matlab command window and a Matlab script? glob-1 ? 'n.. V^" W ?I Aw f eme tw.nhq 3. What is a local variable in the conmext of a Matlab function 4. Ik ware variables differenthetwo nasi ib-n and Matlab Scrir? -mmm 5. Write a Matlab function that converts polar coordinates to rectangular coondinates a. The function accepts two inpat parameters: the radius, and the angle in radians. b. The function creates twe output parameters: the x-coordinate and the y- 6. Write a Matlab Script that prompes the user for a radius and an angle in radians Display the resulting (x. y) coordinale pair

Explanation / Answer

4)
Matlab Function vs Matlab script

The variables in matlab script that store the variables values in the base workspace.
The variables declared in side the function are stored within function and and are not
visible outside of the function.

--------------------------------------------------------------------------------------------------
5)
Matlab function , polar2rectangular that takes radius and angle as input
arguments and then convert the polar coordinates to the rectangular
coordinates.

#polar2rectangular.m
function [x,y]=polar2rectangular(radius,angle)
inRad= deg2rad(angle);
#calculate x value
x=radius*cos(inRad);
#calculate y value
y=radius*sin(inRad);
end

Sample Output :
>>   
x=7.071068
y=7.071068

--------------------------------------------------------------------------------------------------
6)
#Matlab script that prompts user to enter radius and angle
fprintf('Polare co-ordinates to rectangular co-ordinates ')
radius = input('Enter radius: ');
angle = input('Enter angle: ');
inRad= deg2rad(angle);
#calculate x value
x=radius*cos(inRad);
#calculate y value
y=radius*sin(inRad);

fprintf('x= %f y= %f ',x,y)

Sample Output :
>>   
Polare co-ordinates to rectangular co-ordinates
Enter radius: 10
Enter angle: 45
x= 7.071068 y= 7.071068

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote