フィルターのクリア

Info

This question is locked. 編集または回答するには再度開いてください。

plotting four variable using meshgrid for 3 variables, but i am getting error

3 ビュー (過去 30 日間)
Zahid
Zahid 2023 年 8 月 31 日
Locked: Rena Berman 2024 年 6 月 5 日
t=0.2;
p=1;
for kx = -3:.1:3
q=1;
for ky = -3:.1:3
r=1;
for kz = -3:.1:3
energy_ary(p,q)= -2*t*(cos(kx)+cos(ky)+cos(kz));
z_ary(r)= kz;
r=r+1;
end
y_ary(q)= ky;
q=q+1;
end
x_ary(p)=kx;
p=p+1;
end
x = x_ary ;
y = y_ary ;
z = z_ary ;
[XX,YY,ZZ] = meshgrid(x,y,z);
EE = energy_ary' ;
surf(XX,YY,ZZ,EE) ;
Error using matlab.graphics.chart.primitive.Surface
Value must be a vector or 2D array of numeric type.

Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
hold all

採用された回答

Walter Roberson
Walter Roberson 2023 年 8 月 31 日
meshgrid with 3 inputs always returns 3 dimensional outputs (unless the third input just happens to be scalar.) So your XX, YY, and ZZ are all going to be 3D. But surf() requires that the first two coordinate systems be either vector or 2D, and that the third coordinates be 2D.
surf() is not suitable for creating 3D cuboid volumes with a value for each interior voxel.
If you have three independent input variables and one dependent output variable, then you should consider: slice or isosurface or volshow
  1 件のコメント
Zahid
Zahid 2023 年 9 月 2 日
Thank you for clarifying. I got it.

その他の回答 (0 件)

This question is locked.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by