Hello everyone,
I can't seem to successfully obtain a graph of the following equation: f(x,y)=sin(x)sin(y)/(x*y). I think it's because the equation is written wrongly but I can't seem to figure out what I did wrong.
Thank you.
>> x=linspace(0, 2*pi);
>> y=linspace(0, 2*pi);
>> [X,Y]=meshgrid(x,y);
>> Z=sin(X)*sin(Y)/(X*Y).;
>> meshz(X,Y,Z)

 채택된 답변

Roger Stafford
Roger Stafford 2016년 5월 8일
편집: Roger Stafford 2016년 5월 8일

0 개 추천

The line
Z=sin(X)*sin(Y)/(X*Y).;
is the trouble. You need dots there:
Z=sin(X).*sin(Y)./(X.*Y);
so as to produce element-by-element operations. As it stands. it is performing matrix multiplication and matrix division which you don’t want here. Also that trailing dot does not belong there.
Also note that at the single point x = 0 and y = 0 you will produce a NaN from a zero-divided-by-zero operation there.

댓글 수: 3

verzhen Ligai
verzhen Ligai 2016년 5월 8일
편집: verzhen Ligai 2016년 5월 8일
Thank you very much for your reply. I modified it and ran it again. However, the result graph is not what I expected.
The graph that I wanted to get is shown in the black/white picture below.
Thank you.
The diagram shows negative and positive coordinates, but you have only plotted over positive coordinates.
verzhen Ligai
verzhen Ligai 2016년 5월 8일
Oh! that makes sense. You are right!!!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

태그

질문:

2016년 5월 8일

댓글:

2016년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by