How to remove position that is not in conditions from a matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I have a small problem, I want remove the position that is not in conditions from a matrix.
For example, If i have A = [ 1 2 1 3 1 2 2 ] and cumsum them ---> B = [ 1 3 4 7 8 10 12 ]
and I want to remove the first position that B>5 or A(1,4) and rearrange to recalculate and repeat them
- A = [ 1 2 1 1 2 2 ] ---> B = [ 1 3 4 5 7 9 ] ---> remove A(1,5)
- A = [ 1 2 1 1 2 ] ---> B = [ 1 3 4 5 7 ] ---> remove A(1,5)
- A = [ 1 2 1 1 ] ---> B = [ 1 3 4 5 ] ---> stop
Thank you for helping me .
0 件のコメント
回答 (1 件)
Image Analyst
2022 年 5 月 18 日
Using find() inside a while loop should allow you to finish this homework problem.
A=
B=
while max(B) > 5
index = find()
if ~isempty(index)
% Code
end
end
etc. I'm sure you can finish it.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!