I've tried running this code but unfortunately it doesn't work because of the 'symPower' is unrecognizable function or variable. Would definitely appreciate the help. Thanks

1 vue (au cours des 30 derniers jours)
function [powerFactor,decOrder] = allocatePower(symPower,gainH,targetSNR_1,targetSNR_2,nVar)
% This function is to allocate transmit power to users based on their
% channel gain. The power is allocated to make both users achieve a target
% SNR.
[numUE,numSC] = size(gainH);
% Channel gain levels
gainDiff = diff(gainH,[],1); % column2-column1
highGain(logical(gainDiff<0)) = 1;
highGain(logical(gainDiff>0)) = 2;
lowGain(logical(gainDiff>0)) = 1;
lowGain(logical(gainDiff<0)) = 2;
highGain = highGain.';
lowGain = lowGain.';
% Calculate power allocation factor
powerFactor = zeros(numSC,numUE);
for sc = 1:numSC
lowPower = targetSNR_2*nVar./(symPower*gainH(highGain(sc),sc));
highPower = (targetSNR_1*(lowPower.*symPower*gainH(highGain(sc),sc)+nVar))./symPower*gainH(lowGain(sc),sc);
highPowerFactor = highPower./(highPower+lowPower);
lowPowerFactor = lowPower./(highPower+lowPower);
powerFactor(sc,highGain(sc)) = lowPowerFactor;
powerFactor(sc,lowGain(sc)) = highPowerFactor;
end
decOrder = zeros(numSC,numUE);
[~,decOrder(:,1)] = max(powerFactor,[],2);
[~,decOrder(:,2)] = min(powerFactor,[],2);
Output: allocatePower(symPower, gainH, targetSNR_1, targetSNR_2, nVar)
Unrecognized function or variable 'symPower'.

Réponses (1)

Vijay
Vijay le 14 Oct 2022
Hello @Kaeshwin
Please make sure all variables are defined before using them.
For example
symPower, on of the variables used while calling, must be defined first
you need to define all the variables before calling the function allocatePower.
Example Values:
symPower = 1;
gainH = 0.2;
targetSNR_1 = 10;
targetSNR_2 = 20;
nvar=100;
%above values are just for example, please chose suitable values.
[output_1, output_2] = allocatePower(symPower, gainH, taragetSNR_1, targetSNR_2, nvar);

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by