remove and save row of matrix in while loop
1 回表示 (過去 30 日間)
古いコメントを表示
NA
2019 年 11 月 27 日
回答済み: JESUS DAVID ARIZA ROYETH
2019 年 11 月 27 日
I have
remove_b=[]
a=[0,1,1,1,1,0,1;0,0,1,1,0,1,1;0,0,0,1,1,0,1;0,0,0,0, 1,1,0;0,0,0,0,0,0,0];
b=[1,1;1,2;1,4;1,5;1,9];
[n1,i]=max(sum(a~=0,2));
while loop
while (n1~=1) && (n1~=0)
b(i,:)=[];
remove_b=b(i,:);
a(i,:)=[];
[n1,i]=max(sum(a~=0,2));
end
I want to save remove_b in while loop
result should be
remove_b=[1,2;1,4;1,5;1,9]
0 件のコメント
採用された回答
JESUS DAVID ARIZA ROYETH
2019 年 11 月 27 日
With a cycle as you require:
remove_b = []
a = [0,1,1,1,1,0,1; 0,0,1,1,0,1,1; 0,0,0,1,1,0,1; 0,0,0 , 0, 1,1,0; 0,0,0,0,0,0,0];
b = [1.1; 1.2; 1.4; 1.5; 1.9];
[n1, i] = max (sum (a ~ = 0.2));
while (n1 ~ = 1) && (n1 ~ = 0)
b (i,:) = [];
remove_b = vertcat (remove_b, b (i, :));
a (i,:) = [];
[n1, i] = max (sum (a ~ = 0.2));
end
disp (remove_b)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!