Hi Shama,
In my understanding, you have a 4D array “optimal_power” with the dimensions: “EbNo, no_packets, no_OFDM_symbols, no_subcarriers”. You are attempting to calculate the average power for each packet, each ‘Eb/No’ value and each ‘OFDM’ symbol where the result should have the dimensions: “no_OFDM_symbols, EbNo, no_packets”.
Taking the average to get average power involves summing over the last dimension of the array which is “no_subcarriers”, then dividing this sum by the number of subcarriers and finally using the “permute” function to get the array in the expected dimension.
The following code snippet demonstrates the use of “permute” function and how the average can be calculated:
% Calculate sum over no_subcarriers dimension
sum_power = sum(optimal_power, 4);
% Calculate average power
Average_power_default = sum_power / Nof_Subcarriers;
% Permute the dimensions
Average_power = permute(Average_power_default, [3 1 2]);
“Average_power_default” will be a 3D array with dimensions: “EbNo, no_packets, no_OFDM_symbols”, which represents the average power for each ‘Eb/No’ value, each packet, and each ‘OFDM’ symbol. "Average_power" represents the array with expected dimension.
While using the “Gamma_SNR” function, you should pass the entire 4D array “optimal_power” and let the function handle the indexing itself. If the need is to pass only a specific part of the array the”:” operator can be used to select all elements belonging to a specific dimension.
Please refer to the following MathWorks documentation link for more information on “permute” function:
Please refer to the following MathWorks documentation link for more information on array indexing:
Hope this helps!