Trying to produce a meshgrid 3D plot using surf graphs, error using *

I am trying to make a surf graph for the equation:
Z=[ x(1-y)] / [(1+x)(x+y) ]
Here is what I have so far:
x = 0:1:100;
y = 0:10:1000;
[X,Y]=meshgrid(x,y);
Z=(x-x*y)/(x+x^2+y+x*y)
surf(X,Y,Z')
The error code is:
Incorrect dimensions for matrix multiplication. Check that the
number of columns in the first matrix matches the number of rows in
the second matrix. To perform elementwise multiplication, use '.*'.
Can someone please help me with this? I believe I am using multiplication correctly but I could very likely be wrong.

답변 (1개)

KSSV
KSSV 2021년 6월 21일
편집: KSSV 2021년 6월 21일
Read about element by element operations.
x = 0:1:100;
y = 0:10:1000;
[X,Y]=meshgrid(x,y);
Z=(X-X.*Y)./(X+X.^2+Y+X.*Y) ;
surf(X,Y,Z)

댓글 수: 2

Thank you so much!
Thanks is accepting/ voting the answer.

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

카테고리

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

태그

질문:

2021년 6월 21일

댓글:

2021년 6월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by