Plotting CST Farfield Polar Plot to Matlab

조회 수: 21 (최근 30일)
Mashrur Zawad
Mashrur Zawad 2023년 6월 5일
댓글: Govind KM 2023년 6월 5일
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 Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by