How to iteratively delete rows of a matrix?

4 ビュー (過去 30 日間)
Cantor Set
Cantor Set 2020 年 2 月 29 日
回答済み: David Hill 2020 年 2 月 29 日
suppose I have a matrix P and v, both have the same number of rows.and v has only one column.
I need to write a loop which excutes the following:
if the 1st element in v < tol then remove the 1st row from P.
L=size(v,1);
%id is a vector where each element contains the position of the rows that must be deleted in P
for i=1:L
z=v(i);
if z<tol
id=[id;i];
else
1;
end
end
so for example if id= [1 ;50; 100]; this mean I need to remove from P the 1st, the 50th and the 100th row from P
How shall I proceed ?
Thanks

採用された回答

David Hill
David Hill 2020 年 2 月 29 日
P(v<tol,:)=[];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by