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

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

View Full Document Right Arrow Icon
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.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern