how to write fraction function in complex plane by using matlab

조회 수: 25 (최근 30일)
Aisha Mohamed
Aisha Mohamed 2022년 2월 8일
답변: Sphiwe 2023년 10월 15일
Hi
I worked in ploting function defined in complex plane by using matlab I know we can write the polynomial in matlab by using its coefficients
for example f(z)= (2-8i)Z^3+(2+3i)Z^2 + (1+5i)Z+ (3-4i) this equation can be written in matlab as p=[(2-8i) (2+3i) (1+5i) (3-4i) ],. But when we find this equation f(z)= (2-8i)/Z^3+(2+3i)/Z^2 + (1+5i)/Z+ (3-4i) how can I write this equation in matlab? I mean here the complex variables in the Denominator
Thanks
  댓글 수: 1
Benjamin Thompson
Benjamin Thompson 2022년 2월 8일
MATLAB supports complex numbers. See documentation on the topic "complex". Are you trying to write the equation symbolically using the Symbolic Toolbox, or numerically to calculate answers at specific values of Z or to plot over a range of the complex plane?

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

채택된 답변

John D'Errico
John D'Errico 2022년 2월 8일
MATLAB has a simple form to allow you to store only the coefficients of a polynomial. You aready know that. But there is no simple form to allow you to store some arbitrary function. In this case, you wish to store the coefficients of a function that uses inverse powers of a variable Z. Luckily, you can cheat, just a bit. That is, if you have the coefficients as a vector as you do here,
(2-8i)/Z^3+(2+3i)/Z^2 + (1+5i)/Z+ (3-4i)
So you have just the vector:
p = [(2-8i) (2+3i) (1+5i) (3-4i)];
Then you can evaluate it using polyval as:
z = 1:3;
polyval(p,1./z)
ans =
8.0000 - 4.0000i 4.2500 - 1.7500i 3.6296 - 2.2963i
That is, we just think of this as a simple polynomial in powers of 1/z, so compute the inverse of z, THEN use polyval on those values.
  댓글 수: 5
John D'Errico
John D'Errico 2022년 2월 13일
편집: John D'Errico 2022년 2월 13일
I did not ignore two things. I answered the question you asked. You did NOT ask how to find the zeros of a function. You asked how to write what is effectively a polynomial in 1/Z.
My choice of 1:3 is irrelevant, I picked it as an example.
You then say that polyval may not be appropriate. Why not? It evaluates the polynomial that you give it. For example, you gave these coefficients.
format long g
p = [(2-8i) (2+3i) (1+5i) (3-4i)];
z = 1 + 3i;
polyval(p,1./z)
ans =
4.712 - 3.916i
Is that the correct value? Test it.
sum(p.*z.^(-3:1:0))
ans =
4.712 - 3.916i
Note that the above line of code applies ONLY for scalar values of z. However it clearly agrees with polyval.
As far as zeroes goes, please show me where in your question where you EXPLICITLY said even a single word about the zeros of this function? Here is the statement of your question, just in case you forgot:
"I worked in ploting function defined in complex plane by using matlab I know we can write the polynomial in matlab by using its coefficients
for example f(z)= (2-8i)Z^3+(2+3i)Z^2 + (1+5i)Z+ (3-4i) this equation can be written in matlab as p=[(2-8i) (2+3i) (1+5i) (3-4i) ],. But when we find this equation f(z)= (2-8i)/Z^3+(2+3i)/Z^2 + (1+5i)/Z+ (3-4i) how can I write this equation in matlab? I mean here the complex variables in the Denominator:"
That was your exact statement. Yes, you finally added the word zeros in a final comment. Sorry for expressing irritation, but should I be able to read your mind? SIGH. Maybe you were thinking about zeros. But don't tell me that I did not answer the question you asked.
Ok. You want to find the zeros of this function? Still trivial.
proots = 1./roots(p)
proots =
-1.05497409102958 + 0.115399209863617i 0.705937495228178 + 0.539274174004756i 1.0290365958014 - 1.41467338386837i
Now evaluate the function at those points. I will use polyval.
polyval(p,1./proots)
ans =
-8.88178419700125e-15 + 1.06581410364015e-14i 2.39808173319034e-14 - 1.02140518265514e-14i 8.88178419700125e-16 + 8.88178419700125e-16i
So zero, to within floating point trash. proots contains the zeros of the indicated polynomial in powers of 1/z.
Aisha Mohamed
Aisha Mohamed 2022년 3월 14일
Hi John
Sorry for bothering you, it was nice explaination, that encorge me to ask more help please,
I work in both function f(z) and f(1/z) and the coefficiens of both change with time t. and z is complex number.
For example time = 0:0.01:2*pi at every time t I have to find f(z) and f(1/z) and plot them in order to find the graphs of these functions.
This is what I did:
I used (for loop )to calculate the coefficient at every time ( time = 0:0.01:2*pi ) and the coefficients of f(z) as well. Then at each time t and its corresponding coefficients I plot p=f(z) and polyval(p,1./z)[by using your idea (Thank you very much)]but I have to choose spicific value of z to plot polyval(p,1./z) .
The problem is how to check these graphs are correct? and how can me plot both function in whole complex plane(arbitrary values of z)
Thank you very much

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

추가 답변 (1개)

Sphiwe
Sphiwe 2023년 10월 15일
num = [1]
den= conv([1 3 5], [1 3], [1 5])
g = tf (num,den)
[z,p,k] = tf2zp(num,den)
pzmap(g)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by