Plotting CST Farfield Polar Plot to Matlab
43 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I would like to plot 1D Farfield radition pattern in matlab from CST.I have saved the file as text from CST but while I am reading the file in matlab and trying to plotting it is showing error. I have used the following code :
% Specify the file name
filename = '2.8off.txt'; % Replace with the name of your CST text file
% Read the data from the text file
data = readmatrix(filename);
% Extract the relevant columns
theta_deg = data(:, 1) % Theta [deg.]
phi_deg = data(:, 2); % Phi [deg.]
absDir = data(:, 3); % Abs(Dir.) [dBi]
% Convert angles to radians
theta_rad = deg2rad(theta_deg);
phi_rad = deg2rad(phi_deg);
% Plot the radiation pattern
polarplot(theta_rad, absDir, 'LineWidth', 2);
title('CST Polar Data');
But After running this I am getting this error : >> RP
Index in position 2 exceeds array bounds. Index must not exceed 1.
Error in RP (line 9)
phi_deg = data(:, 2); % Phi [deg.]
Can you please let me know how to solve it. For your information first column represent Theta [deg.], second columnPhi [deg.] and third column Abs(Dir.)[dBi ] fourth column Abs(Theta)[dBi ] ,fifth column Phase(Theta)[deg.,sixth column Abs(Phi )[dBi ], seventh column Phase(Phi )[deg.] and eighth column Ax.Ratio[dB ]
1 Kommentar
Govind KM
am 5 Jun. 2023
I don't think your text file is being read as a matrix correctly. Can you check the dimensions of data using the size command?
size(data)
Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!