3D surface plotting. Error (z must be a matrix)

x_length=50;
for y_length=0:200;
z_length=y_length;
%[z,y]=meshgrid(z_length,y_length);
%i=0:200;
Hyp1=sqrt((x_length.^2)+(y_length.^2));
Hyp2=sqrt((Hyp1.^2)+(z_length.^2));
ctheta_i=y_length/Hyp2;
Lang_walldb=20*(1-ctheta_i).^2;
surf(Lang_walldb)
grid on
xlabel('y length');
ylabel('z length ');
zlabel('angular loss')
hold on
set(gca,'View',[-29,-22]);
end

2 件のコメント

madhan ravi
madhan ravi 2019 年 4 月 12 日
you never seem to use z & y after meshgrid() call , re-examine why you used it in the first place
Walter Roberson
Walter Roberson 2019 年 4 月 12 日
Nothing in your calculation is a vector, let alone a matrix. Your Lang_walldb is always going to be a scalar at the point you do the surf()

サインインしてコメントする。

 採用された回答

KSSV
KSSV 2019 年 4 月 12 日
編集済み: KSSV 2019 年 4 月 12 日

0 投票

x_length=0:50;
y_length=0:200 ;
[x_length,y_length] = meshgrid(x_length,y_length);
Hyp1=sqrt((x_length.^2)+(y_length.^2));
Hyp2=sqrt((Hyp1.^2)+(y_length.^2));
ctheta_i=y_length./Hyp2; % edited as suggested my Madhan Ravi
Lang_walldb=20*(1-ctheta_i).^2;
surf(Lang_walldb)
shading interp
grid on
xlabel('y length');
ylabel('z length ');
zlabel('angular loss')
hold on
set(gca,'View',[-29,-22]);

2 件のコメント

madhan ravi
madhan ravi 2019 年 4 月 12 日
ctheta_i=y_length./Hyp2; % missed a dot in front of /
KSSV
KSSV 2019 年 4 月 12 日
Yes...edited..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

質問済み:

2019 年 4 月 12 日

編集済み:

2019 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by