Borrar filtros
Borrar filtros

matrix column element limiting

1 visualización (últimos 30 días)
mehrdad asadi
mehrdad asadi el 8 de Jul. de 2015
Editada: Stephen23 el 8 de Jul. de 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,

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 8 de Jul. de 2015
Example
A=rand(200,30)
idx=A(:,29)>0.5 & A(:,30)<0.7
out=A(idx,:)
  4 comentarios
mehrdad asadi
mehrdad asadi el 8 de Jul. de 2015
thank you A.Abdelmalek,
I did this, but because I have 4 constraints, and it should be repeated many times in a for loop, it seems it's not that much optimized! thanks anyway, right now, this is the only solution that crosses the mind.
Stephen23
Stephen23 el 8 de Jul. de 2015
Editada: Stephen23 el 8 de Jul. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by