Using other matrix data for selection in other matrix?

4 views (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 10 Apr 2015
Edited: Stephen23 on 10 Apr 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:

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by