3D plot using matlab

1 回表示 (過去 30 日間)
A A
A A 2013 年 11 月 25 日
コメント済み: A A 2013 年 12 月 2 日
Hey..I'm trying to plot the following code but i keep getting this error: (??? Error using ==> surf at 78 Z must be a matrix, not a scalar or vector.)I tried using mesh i got the same error and whe i tried using plot3 it only resulted in straight line plot and not 3D..Help !!
%%Defining givens:
f= 300e6; %%Chosen frequency
c= 3e8; %%Free space
lambda= c./f; %%Wavelenght
l_2=lambda./2;
k= (2.*pi)./l_2; %%Wave number
Io=5; % Chosen maximum value of the current
eighta=377; % Intrinsic impedance (free space)
r=l_2/(2.*pi); % Distance
h= 0:1:100; %%Variable height from the ground
L=1.25*l_2; % Dipole length
theta= 2*pi; %%Computing the requirements:
%%Electric field:
A= (k.*L.*Io.*exp(-1i.*r.*k))./(4.*pi.*r);
B= 2.*(cos(cos(theta).*k.*h));
E_F= eighta.*1i.*(A).*sin(theta).*(B);
[x,y,z]=sph2cart(h,theta-pi/2,E_F); % Converting to cartesian coordinates
% Generating 3D plot
surf(x,y,z) % Generating 3D plot
colormap(JET);
title ('Electric Field in 3D plot')
legend ('Heigth','Theta','Electric Field')
rotate3D on
axis image

採用された回答

Image Analyst
Image Analyst 2013 年 11 月 25 日
z is complex. You must want to investigate why.
  1 件のコメント
A A
A A 2013 年 12 月 2 日
yaa i know but how can that help me ?

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

その他の回答 (0 件)

カテゴリ

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