getting error in contour plot

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 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeSpecial Functions についてさらに検索

タグ

質問済み:

2019 年 11 月 4 日

回答済み:

2019 年 11 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by