This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 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....
View Full Document
This note was uploaded on 04/01/2008 for the course ENGE 1114 taught by Professor Twknott during the Spring '06 term at Virginia Tech.
- Spring '06