How to plot 3D radiation pattern together from 2 separated .OGL files data in Matlab

22 views (last 30 days)
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.

Answers (1)

Walter Roberson
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
TN
TN on 14 Nov 2024 at 20:54
Hi Walter,
Thanks for your answer. Is there other function that I can use? Unfortunately, the raw data doesn't contain just magE, theta, and phi.
Thanks

Sign in to comment.

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!