Azzera filtri
Azzera filtri

Function to evaluate arguments using pol2cart

3 visualizzazioni (ultimi 30 giorni)
Carlos
Carlos il 29 Mar 2014
Commentato: Marta Salas il 30 Mar 2014
Write a function with input arguments to be the magnitude and angle (in degrees) of a complex number and output argument to be the Cartesian form of the same number, i.e. x+yi.

Risposte (2)

Roger Stafford
Roger Stafford il 29 Mar 2014
Think about how the real and imaginary parts of any complex number are related to its magnitude and angle, and you will have just about solved your problem. The necessary matlab code is easy to write.
  1 Commento
Carlos
Carlos il 29 Mar 2014
Thank you for your prompt response. I do understand the relation of the two components. The problem is that I'm trying to use a function and pol2cart and I don't know how to get about.
Thank you
Code:
function x = Carlos_Virguez_Ex14(5,63)
[X,Y] = pol2cart(63*pi/180, 5);
x = X+Y*1i;

Accedi per commentare.


Marta Salas
Marta Salas il 30 Mar 2014
Modificato: Marta Salas il 30 Mar 2014
As arguments for your function you have to write the name of the variable:
function x = Carlos_Virguez_Ex14(r,angle)
Note: you have to modify the code inside your function to use these variables.
then when you call that function [in the MATLAB's prompt] you assign the values for those variables:
>>Carlos_Virguez_Ex14(5,63)
  2 Commenti
Carlos
Carlos il 30 Mar 2014
Thank you Marta,
I was finally able to run the script, but now I'm getting another error.
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Thanks in advanced
Marta Salas
Marta Salas il 30 Mar 2014
Did you get that error running this script?!

Accedi per commentare.

Categorie

Scopri di più su Trigonometry in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by