Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating antenna radiation pattern in 3D

Status
Not open for further replies.

windell

Mechanical
Jun 16, 2005
26
Hi, I'm quite new to MATLAB and I am working on creating a 3D radiation pattern plot of an antenna that I am testing for a project. The purpose of the plot is really just to get a feel for the radiation pattern. I've already successfully created contour plots at various elevations by overlaying the data on a single plot.

As input I am reading three columns in from a txt file that contains the power level for each elevation and azimuth. I then convert from spherical to Cartesian coordinates and then attempt to make the 3D plot. Upon doing so, I get an error.

%load & store the signal angle of attack values.
load monopole3D.txt
theta = monopole3D:),1);
phi=monopole3D:),2);
r=monopole3D:),3);

%convert to radians.
theta=(pi/180)*theta;
phi=(pi/180)*phi;

%make the radius not negative.
r=r+40;

%convert spherical coordinates to rectangular coordinates.
[x,y,z]=sph2cart(theta,phi,r);
[X,Y,Z]=meshgrid(x,y,z);

%plot in 3D
mesh(X,Y,Z)

Second here is my error.
"Error in ==> meshgrid at 62
zz = zz(ones(ny,1),ones(nx,1),:); Error in ==> v2_plot at 123
[X,Y,Z]=meshgrid(x,y,z);"

Any help would be greatly appreciated! I'm not sure why this isn't working really, but of course the error exist between the keyboard and chair. :)
 
Replies continue below

Recommended for you

probably be a bit of a clue if you told us which was line 123

I'm guessing this one

[X,Y,Z]=meshgrid(x,y,z);

which looks ok but without data etc it is hard to tell.

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Hi Greg, Sorry about that. I moved the code to a separate file and ran it again. I received the following error.

??? CData must be an M-by-N matrix or M-by-N-by-3 array.
Error in ==> mesh at 135
hh = graph3d.surfaceplot(x,y,z,'FaceColor',fc,'EdgeColor','flat', ...
Error in ==> mesh3D at 19
mesh(X,Y,Z)

I'm thinking that the problem has to do with not having all the data as matrices instead of vectors.

Thanks!

I attached the txt file and m-file.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor