The Student Room Group

Complex Numbers - polar to cartesian form - matlab

How do i change the polar form of complex numbers to cartesian form?
Reply 1
Original post by MatthewTG
How do i change the polar form of complex numbers to cartesian form?


re^ixpi=r(cos(x)+isin(x))

x is your argument, r is modulus of z (magnitude of the line), sub in values and you'll have it in the form x+yi
Reply 2
Original post by xyz9856
re^ixpi=r(cos(x)+isin(x))

x is your argument, r is modulus of z (magnitude of the line), sub in values and you'll have it in the form x+yi


how do i do it in matlab?
Here is an example matlab function:

function [real,imaginary] = comp_polar_to_cart(r, theta)
% This function converts complex numbers from polar to cartesian coordinates.
% Input: r - modulus
% theta - complex angle (in rad)

% Output: real - real part
% imaginary - imaginary part

% error check
if numel(r) ~= numel(theta)
error('The input arguments must be of the same length!');
elseif numel(size(r) - size(theta)) ~= 0
error('The input arguments must be of the same dimension!');
end

% Cartesian coordinates:
real = r .* cos(theta);
imaginary = r .* sin(theta);
(edited 7 years ago)
Original post by MatthewTG
How do i change the polar form of complex numbers to cartesian form?


You don't need to do anything since MATLAB expresses each form:

reiθre^{i\theta}
x+iyx+iy
r(cos(θ)+isin(θ))r(\cos(\theta)+i\sin(\theta))

in the form x+iyx+iy when you enter it. So whichever form you enter your complex number, it will get turned into Cartesian.
(edited 7 years ago)
Reply 5
Original post by RDKGames
You don't need to do anything since MATLAB expresses each form:

reiθre^{i\theta}
x+iyx+iy
r(cos(θ)+isin(θ))r(\cos(\theta)+i\sin(\theta))

in the form x+iyx+iy when you enter it. So whichever form you enter your complex number, it will get turned into Cartesian.


I have cartesian matlab results and polar written results. I need to change one set of results to the other form to compare results.

Quick Reply

Latest