deleting a full colum using
1 回表示 (過去 30 日間)
古いコメントを表示
I have a matrix with several optionprice data. Now I am trying to delete rows based on a for loop and if criteria. if the value of column 8 is >1.1 or <0.9, the whole row should be deletet. I have used the following code, but I always get an error message:
for i=1:numel(matrix)
if(matrix(i,8)>1.1)
matrix(i,:) = [];
end
end
1 件のコメント
採用された回答
Jan
2013 年 3 月 17 日
編集済み: Jan
2013 年 3 月 17 日
numel(matrix) is the number of all elements. When you have deleted some rows already, the matrix has less elements and matrix(i,8) might be not existing anymore already.
You do not need a loop, to solve this problem:
matrix(matrix(:, 8) > 1.1, :) = []
0 件のコメント
その他の回答 (1 件)
Locks
2013 年 3 月 17 日
2 件のコメント
Azzi Abdelmalek
2013 年 3 月 17 日
Sven, if the answer helped, click on accept this answer. Also, to add a comment, click on comment on this answer just under the answer.
参考
カテゴリ
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!