Getting an array with data

Hello,
I have a question regarding getting data from an array
I have one array of data. lets say (array 1):
Index Speed # 1 5 # 2 9 # 3 4 # 4 5
(index 1 has value 5 , index 2 has value 9 etc)
I made another array (array= indexdata) which contain the indexnumbers of the values which are interested for me ( lets say i only want to look at index number two which has the value 2).
So how can i program that matlab makes a new array of the values of the first arrays, whose indeces are listed in the second array,
it sounds complicated but what i want is easy :)

 Respuesta aceptada

Vishal Rane
Vishal Rane el 12 de Dic. de 2012

0 votos

So ,
array1 = [ 5 9 4 5] % original array
array2 = [ 2 4 ] % array of indices
array3 = array1(array2) % elements from array1 as per indices listed in array 2

2 comentarios

Hello kity
Hello kity el 12 de Dic. de 2012
hmm i know it was easy
back to basics :)
thank you
José-Luis
José-Luis el 12 de Dic. de 2012
Please accept an answer if it helped you.

Iniciar sesión para comentar.

Más respuestas (1)

Hello kity
Hello kity el 12 de Dic. de 2012

0 votos

Answer of Vishal was sufficient. But thanks.
But i have a similar question..
assume there is a set of data/rows with NaN's in between them seperating.
i now have the begin and end indexes of each set of data.
for example indices 1 -7 then 2 nans , 9-15 , 2 nans ,18-24 etc.
i have 3 arrays, 1st array set of data, 2nd array indices with begin of row/data, 3rd array end of set of data.
so if continue on example, 2nd array 1 , 9 , 18 and 3rd array 7 , 15 ,24 now all i want is the values between 1 - 7 and 9 -15 and 18-24
hope its clear

1 comentario

Vishal Rane
Vishal Rane el 12 de Dic. de 2012
Recommend you to create a separate thread for this question, since this question is already marked as answered.

Iniciar sesión para comentar.

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by