matrix column element limiting
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
mehrdad asadi
il 8 Lug 2015
Modificato: Stephen23
il 8 Lug 2015
hi,
I have a matrix say 200*30. I need to limit the elements of 29th and 30th columns with different constraints. how can I do that?
thanks,
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 8 Lug 2015
Example
A=rand(200,30)
idx=A(:,29)>0.5 & A(:,30)<0.7
out=A(idx,:)
4 Commenti
Stephen23
il 8 Lug 2015
Modificato: Stephen23
il 8 Lug 2015
Azzi Abdelmalek's solution is much more optimized than using a loop. This is how MATLAB works best, using basic code vectorization and indexing.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements 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!