How to plot 3D radiation pattern together from 2 separated .OGL files data in Matlab
22 views (last 30 days)
Show older comments
Hello,
I am trying to plot 2 raw data into one 3D radiation pattern plot. The raw data .txt file contain 4 columns (column 1: magE in dB, column 2: x axis, column 3: y axis, column 4: z axis). Please see below code:
% Read the data from both files
data1 = readmatrix('F902.txt');
magE1 = data1(:, 1);
x1 = data1(:, 2);
y1 = data1(:, 3);
z1 = data1(:, 4);
data2 = readmatrix('F915.txt');
magE2 = data2(:, 1);
x2 = data2(:, 2);
y2 = data2(:, 3);
z2 = data2(:, 4);
% Plot both radiation patterns
figure;
patternCustom(magE1, x1, y1, z1);
title('Radiation Pattern from F902.txt');
figure;
patternCustom(magE2, x2, y2, z2);
title('Radiation Pattern from F915.txt');
Errors:
Error using patternCustom
The value of 'theta' is invalid. Expected input to be finite.
Error in patternCustom (line 102)
parse(parseobj, MagE, theta, phi, varargin{:});
Error in Plot3D_2 (line 16)
patternCustom(magE1, x1, y1, z1);
Please advise. I also attached 2 .txt files. In addition, is there other way to perform this plot?
Thanks alot.
0 Comments
Answers (1)
Walter Roberson
on 14 Nov 2024 at 20:39
patternCustom() does not accept x y z vectors. patternCustom accepts magE array or vector, and theta and phi vectors.
(In the case where magE is a vector, it must be N x 1 where N is the length of both theta and phi. Your code happens to match this restriction.)
2 Comments
Walter Roberson
on 14 Nov 2024 at 21:15
You could consider using
[theta,rho] = cart2pol(x,y,z);
See Also
Categories
Find more on Graphics Object Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!