Error using mesh, Z must be a matrix

14 ビュー (過去 30 日間)
Espen André
Espen André 2014 年 10 月 21 日
編集済み: Mischa Kim 2014 年 10 月 21 日
I don't know why, but z won't be registered as a martix even when it calculates it as amtrix.
x=linspace(0,4,2);
y=linspace(0,4,2);
z=sin(pi.*x).*sin(pi.*y);
mesh(x,y,z)

採用された回答

Mischa Kim
Mischa Kim 2014 年 10 月 21 日
編集済み: Mischa Kim 2014 年 10 月 21 日
Espen, use
x = linspace(0,4,20);
y = linspace(0,4,20);
[X,Y] = meshgrid(x,y); % create a grid of data points
Z = sin(pi.*X).*sin(pi.*Y);
mesh(X,Y,Z)
Z needs to be an n-by-m, just like X and Y.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by