EngE_1114_HW6

# EngE_1114_HW6 - 12:20 M | 1 EngE 1114 HW6 | 7 February 2006...

• Notes
• 4

This preview shows pages 1–2. Sign up to view the full content.

1) Given: The coordinate (X,Y) Required: Flowchart, MatLab code, and samples runs Relationships: a 2 + b 2 = c 2 ; tan(Y/X) = ө Solution: % This function will convert the coordinate from rectangular % to polar form when provided with x and y % Call statement: rect_to_polar X = input( 'Enter the value of X: ' ); Y = input( 'Enter the value of Y: ' ); R = (X^(2)+Y^(2))^(1/2); if  R ==0      theta = 0;      fprintf( '\n Polar coordinate does not exist.\n' elseif  X == 0 theta = asind(Y/R);  else theta = atand(Y/X); end if  X<0      if  Y<0          theta = theta - 180;       else  theta = theta + 180;       end end fprintf( '\n R = %f, theta = %.2f. \n' ,R,theta) >> rect_to_polar Enter the value of X: 5 Enter the value of Y: 0 R = 5.000000, theta = 0.00. >> rect_to_polar Enter the value of X: -5 Enter the value of Y: 0 R = 5.000000, theta = 180.00. >> rect_to_polar Enter the value of X: 0 Enter the value of Y: 5 R = 5.000000, theta = 90.00.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern