Plotting CST Farfield Polar Plot to Matlab

31 次查看(过去 30 天)
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 个评论
Govind KM
Govind KM 2023-6-5
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)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by