Incorrect 3d graph of Complex Function (with Singular Matrix Error)

Hi,
I need to plot complex functions with x and y representing real and imaginary parts of the number, the z axis representing the value of my function.
I am using surfc for this but end up getting an obscure graph, along with the warning: matrix is close to singular or badly scaled.
The method I am using works perfectly for something simple like just plotting abs(z) but not for (e^z)/(z-2).
How can I resolve this?
My code is attached below. (I am using matlab online)
Any help would be greatly appreciated. Thanks in advance!
a = -500:10:500;
b = -500:10:500;
[A,B] = meshgrid(a,b);
z = A + 1i*B;
f = (exp(z))/(z-2)
surfc(a,b,abs(f))

 채택된 답변

Use element-wise division —
f = (exp(z))./(z-2);
a = -500:10:500;
b = -500:10:500;
[A,B] = meshgrid(a,b);
z = A + 1i*B;
f = (exp(z))./(z-2);
surfc(a,b,abs(f))
shading('interp')
.

댓글 수: 2

I have been stuck here for 2 days. Feel stupid to realise that this was what I was missing.
Thank you so much!
As always, my pleasure!
Definitely not stupid! If it makes you feel any better, not using element-wise division is the most frequent problem I see here on Answers.
.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 4월 20일

댓글:

2022년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by