Using antenna magnitude data to plot max gain vs frequency

8 views (last 30 days)
I have a set of antenna data which contains a frequency array, azimuth array, and a matrix of magnitude values; see attached photo for how data is arranged. (I have already read in these data sets from an excel file and placed them into their designated arrays/matrix).
I need to plot max gain vs. frequency from this data without using the antenna tool box. Does anyone know the matlab code to calculate antenna gain from frequency, azimuth, and magnitude?

Answers (1)

Abhimenyu
Abhimenyu on 21 Apr 2024 at 14:34
Edited: Abhimenyu on 23 Apr 2024 at 10:16
Hi Samantha,
From the information shared, I could infer that you want to plot maximum gain versus frequency from the antenna magnitude data. As shown in the attached image, frequency is a 1-D array and magnitude is a 2-D matrix where each column corresponds to a frequency. To plot maximum gain versus frequency, the first step would be to convert the magnitude values to decibels, then use MATLAB's "max" function on every column to find maximum gain at each frequency and finally using the "plot" function to visualise the plot required.
Please follow the below-mentioned example MATLAB code to plot max gain versus frequency:
% Generating fake data for demonstration
frequency = linspace(1e9, 10e9, 100); % Frequency array (1 GHz to 10 GHz)
azimuth = linspace(0, 360, 36); % Azimuth array (0° to 360°)
magnitude = rand(size(azimuth, 2), size(frequency, 2)) * 20; % Random magnitude values (between 0 and 20)
% Convert magnitude to dB
gainInDB = 10 * log10(magnitude);
% Calculate max gain for each frequency
maxGain = max(gainInDB, [], 1);
% Plot max gain vs. frequency
figure;
plot(frequency, maxGain, 'b', 'LineWidth', 2);
xlabel('Frequency (Hz)');
ylabel('Max Gain (dB)');
title('Max Gain vs Frequency');
grid on;
For more information on the "max" function, please follow this MATLAB R2024a documentation link: https://www.mathworks.com/help/matlab/ref/max.html
I hope this helps!

Community Treasure Hunt

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

Start Hunting!