How to choose only certain values my matrix answer

6 visualizaciones (últimos 30 días)
Krishma Gold
Krishma Gold el 12 de Sept. de 2019
Comentada: Krishma Gold el 14 de Sept. de 2019
Hi. Grateful for any help please.
My output is in matrix, say 400 563 674 904 789
Now i want to use 563 to 904, as a matrix in another algorithm without me redefining it.
Many thanks

Respuestas (2)

David Hill
David Hill el 12 de Sept. de 2019
A=[400,563,674,904,789];
B=A(A>=563&A<=904);
  3 comentarios
David Hill
David Hill el 14 de Sept. de 2019
My B above gives you that output. If you want a column vector just add an apostrophe.
A=[400,563,674,904,789];
B=A(A>=563&A<=904)';
Krishma Gold
Krishma Gold el 14 de Sept. de 2019
thank you

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 14 de Sept. de 2019
A=[400,563,674,904,789];
idx1 = find(A>=563, 1, 'first');
idx2 = find(A>=904, 1, 'first');
A(idx1:idx2)
but I suspect what you might be looking for is:
A(2:end-1)
  1 comentario
Krishma Gold
Krishma Gold el 14 de Sept. de 2019
Thank you
you are right ....A(2:end-1).... works perfectly

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by