This is a part of a code and I want to add something to it, description below

%This is a part of a code and I want to add something to it so instead of Deleting all the Users row from Heff that corresponding to P=0 in each itretion, I want to delete only the first row that corresponding to P=0 in each itretion
do_Water_filling = 1;
while do_Water_filling
W = pinv(Heff'); %Precoding Matrix
W_bar = ((W./sqrt(sum(abs(W.^2),1))));
D_Matrix = Heff'*W_bar; %Diagonal Matrix
D_Square = (abs(diag(D_Matrix))').^2; %Channel Gains
P = waterfill(Pt,Pn./D_Square);
if any(P==0)
Heff(:,P==0) = []; %Delete User Row
else
do_Water_filling = 0;
end
end

5 件のコメント

Rik
Rik 2021 年 9 月 17 日
Then you shouldn't do Heff(:,P==0) = [];. What have you tried so far to find the first occurence only of P==0?
what are the dimensions of your P and Heff? Or type
whos
to get the dimensions
Matthew Worker
Matthew Worker 2021 年 9 月 17 日
you do not need dimensions, if P=0 if it is the third one in the P array that means the third row of Heff will be deleted,
but the problem sometimes P has more than one value equal to zero (you have zero in position 3 and 4 in the P array) so I want only the first value of P that is equal to zero so I will delete the third row of Heff, from this example in my code I will delete the row 3 and 4 and I do not want that, I only need to delete one row in each iteration so I want to delete the third row only.
Matthew Worker
Matthew Worker 2021 年 9 月 17 日
I want to find the first zero value of P and delete the row of Heff that corresponding to this position
Rena Berman
Rena Berman 2021 年 12 月 16 日
(Answers Dev) Restored edit

サインインしてコメントする。

 採用された回答

Mohammad Sami
Mohammad Sami 2021 年 9 月 17 日
In your code
Heff(:,P==0) = []; %Delete User Row
This will actually delete columns not rows in Heff. Not sure if that is what you intended.
Anyways to delete only the first Row / Column in Heff, just use find function to return only the first index.
Heff(:,find(P==0,1)) = []; %find the first index of p == 0 and delete the corresponding col in Hef

1 件のコメント

Matthew Worker
Matthew Worker 2021 年 9 月 17 日
yes you right I am sorry I want to delete the Heff Column

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Elementary Math についてさらに検索

タグ

質問済み:

2021 年 9 月 17 日

編集済み:

2021 年 12 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by