finding data in a matrix

7 visualizaciones (últimos 30 días)
Lilya
Lilya el 29 de Oct. de 2018
Comentada: Lilya el 29 de Oct. de 2018
Hi all,
I am in a trouble :( i do have a matrix of 251*28 that I want to extract the data by giving x and y values (columns(28) and rows(251)). ex
ineedX = find(Xgrid >= 12 & Xgrid <=60); % the extracted data
ineedY = find(Zgrid>= -75 & Zgrid <=-60); % the extracted data
the find command is not working when I want to apply the function as it gives a vector which I want the matrix.
any help? Thanks a lot!

Respuesta aceptada

Bruno Luong
Bruno Luong el 29 de Oct. de 2018
Depending on how your data is organized, (you did not tell if x is first index or second) after doing
ineedX = find(Xgrid >= 12 & Xgrid <=60); % the extracted INDEX
ineedY = find(Zgrid>= -75 & Zgrid <=-60); % the extracted INDEX
you should do
DataExtract = Data(ineedX,ineedY)
Where Data is your original matrix. Or the reverse in indexes if you have x in second dimension.
  1 comentario
Lilya
Lilya el 29 de Oct. de 2018
SUPER! Thanks a lot..

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 29 de Oct. de 2018
A = rand(251,28) ;
A(251,28) % this gives you 251 row and 28 column
Read about logical indexing. Don't use find.It will be slow.
Also read about ind2sub and sub2ind.
  1 comentario
Lilya
Lilya el 29 de Oct. de 2018
Thank you so much KSSV.. ur answers are always very helpful

Iniciar sesión para comentar.

Categorías

Más información sobre Matrices and Arrays 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