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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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'.
0 Commenti
Risposte (1)
Vijay
il 14 Ott 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);
0 Commenti
Vedere anche
Categorie
Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!