Using other matrix data for selection in other matrix?

1 visualización (últimos 30 días)
Wouter Stg
Wouter Stg el 10 de Abr. de 2015
Editada: Stephen23 el 10 de Abr. de 2015
Hi, I'm currently working on some trigger data, and I've got my self te samplenumber when the trigger hits. This number is saved in a new matrix called Trigger
  • Trigger=N*1 (N=depending on the number of triggers) containing the samplenumber at which a trigger is found
  • Data= N*1(N= depending on number of samplenumber, around (20000)contains measurement data
Now what i want to do is select the data by the triggers. So the Value in "trigger" should be used in the function to extract values out of "Data".
What i tried is to create a new variable A1
A1= (Data(Trigger(1,1):Data(Trigger(2,1)) but i couldn't figure it out.
Thanks, Wouter
  2 comentarios
Stephen23
Stephen23 el 10 de Abr. de 2015
Editada: Stephen23 el 10 de Abr. de 2015
This explanation is confusing, and it should be edited: it would be easier if you simply listed the variables, their size, and what they are for:
  • data, numeric of size 5x20000. Contains the data to be extracted. Each row corresponds to ..., each column is ...
  • samplenum, numeric of size 1x1. Contains the value of ...
  • triggernum, numeric of size 1xN. Contains the sum of how many ...
or something like that. And then tell us how the rows and columns to be extracted relate to the variables that you define.
Currently the variable nomenclature (naming) is not clear: what values are defined and which are just explanations, and then in the last sentence B does not get referred to at all, and both x and X suddenly appear without being defined.
Wouter Stg
Wouter Stg el 10 de Abr. de 2015
Hope this is more understandable

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 10 de Abr. de 2015
Editada: Stephen23 el 10 de Abr. de 2015
How to use indices in MATLAB is covered in the documentation:
You could use subscript indices to select the parts of the data matrix that you require.
EDIT based on the edited question, you could probably simply do this:
>> B = Data(Trigger)
Something like this:
>> Data = 100+(1:9).';
>> Trigger = [6;3;7;8;5;1;2;4;9];
>> Data(Trigger)
ans =
106
103
107
108
105
101
102
104
109
retrieves the values in Data according to the sequence of values in Trigger. If you only need the data values for some particular Trigger valuese, then you can select only these ones:
>> Data(Trigger([1,2,9]))
ans =
106
103
109
You might like to consider doing these tutorials, they will help you to understand and use MATLAB effectively:

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by