How to remove position that is not in conditions from a matrix?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Image Analyst
il 18 Mag 2022
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 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!