Borrar filtros
Borrar filtros

Taking only the first element

46 visualizaciones (últimos 30 días)
Shehab Tarek
Shehab Tarek el 26 de Mayo de 2020
Comentada: Tommy el 26 de Mayo de 2020
I have matrix =[0,2 ;0,25 ;0,25;0,3] And I am using find function To get the index of every element The error occur when the search value is 0,25 it give an output [2,3] And I want to take only the first element of the output array Or the second element
  5 comentarios
Shehab Tarek
Shehab Tarek el 26 de Mayo de 2020
Thank you 🙏
Tommy
Tommy el 26 de Mayo de 2020
To get only the nth index:
matrix = [0.2 ;0.25 ;0.25;0.3];
n = 2;
allIdx = find(matrix==0.25,n);
nIdx = allIdx(end);

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Matrix Indexing 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