필터 지우기
필터 지우기

Function to evaluate arguments using pol2cart

조회 수: 3 (최근 30일)
Carlos
Carlos 2014년 3월 29일
댓글: Marta Salas 2014년 3월 30일
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.

답변 (2개)

Roger Stafford
Roger Stafford 2014년 3월 29일
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
Carlos
Carlos 2014년 3월 29일
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;

댓글을 달려면 로그인하십시오.


Marta Salas
Marta Salas 2014년 3월 30일
편집: Marta Salas 2014년 3월 30일
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
Carlos
Carlos 2014년 3월 30일
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 2014년 3월 30일
Did you get that error running this script?!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Trigonometry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by