getting error in contour plot

조회 수: 4 (최근 30일)
Narayan Das Ahirwar
Narayan Das Ahirwar 2019년 11월 4일
답변: Star Strider 2019년 11월 4일
z = psi(1:ny,1:nx);
X = linspace(0,1, size(z,2));
Y = linspace(0,1,size(z,1));
contour(X,Y)
when i run my program code " i'm getting an error of z matrix must be 2*2 matrix"
but my z function is 51*51 matrix .So what is the error in code.
  댓글 수: 1
Bhaskar R
Bhaskar R 2019년 11월 4일
Function psi is allowed only scalar value as first argument.
ny, nx values are not provided

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

답변 (1개)

Star Strider
Star Strider 2019년 11월 4일
Try this:
nx = 50;
ny = 50;
z = psi((1:ny)'*(1:nx));
X = linspace(0,1, size(z,2));
Y = linspace(0,1,size(z,1));
contour(X,Y,z)
The argument to psi may be a matrix (note the column*row vector multiplication to create the psi argument matrix), and the ‘Z’ argument to contour must be a matrix.
Experiment to get different results.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by