How to convert numbers from Polar to Cartesian form and vice versa

Among other Basic Matlab tutorials here on tutorial45, we are bringing this one along as a quick tip to help you convert numbers from Polar to Cartesian in Matlab.

We all know how to manually convert numbers from Cartesian to Polar and from Polar to Cartesian, Here we will try to get introduced to the Matlab functions that help you quickly convert numbers from Polar to Cartesian form and the vice versa.

Convert from Polar to Cartesian form in Matlab

To convert a number from Polar to Cartesian form in Matlab, you can make use of the pol2cart function. And it goes like this.

Let say we have the following number to convert


Where the radius and the angle are respectively


Here is how you will actually do it with Matlab

[RealPart, ImagPart]=pol2cart(-3*pi/4,4);
disp(['Real= ',num2str(RealPart),'; imag= ', num2str(ImagPart)]);

Which displays


Convert from Cartesian to Polar form

Converting from Cartesian to Polar is a little tricky, since the value of the angle could be misinterpreted.

Let’s convert the following


in Polar form

To do this in Matlab, use the following.

disp(['mag= ',num2str(mag),'; rad= ',num2str(rad),'; deg= ',num2str(deg)]);

Which prints

Here we converted the result from radiant to degree.

Hope you have learned a few new tricks today. Feel free to drop your concern below if needed.


Related Posts