フィルターのクリア

How to efficiently delete rows from very large matrix

1 回表示 (過去 30 日間)
Sami Seppälä
Sami Seppälä 2022 年 3 月 10 日
コメント済み: Sami Seppälä 2022 年 3 月 11 日
I have to delete rows from a very large matrix (in order of 2 000 000x30). I am currently using the following code the code does this very slowly. Currently going through one matrix takes a couple of hours.
[n,m] = size(data);
%%% nan check
data_nan_checked =zeros(1,m);
ok_row_count = 0;
for i = 1:n
nan_found = 0;
for j = start_column:end_column
if isnan(data(i,j))
nan_found = 1;
end
end
if nan_found == 0 %&& row_ave > 0
ok_row_count = ok_row_count + 1;
data_nan_checked(ok_row_count,:) = data(i,:);
end
end

採用された回答

Torsten
Torsten 2022 年 3 月 10 日
data(any(isnan(data),2),:) = [];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDynamic System Models についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by