- 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 ...
Using other matrix data for selection in other matrix?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2015-4-10
编辑:Stephen23
2015-4-10
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:
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.
采纳的回答
Stephen23
2015-4-10
编辑:Stephen23
2015-4-10
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:
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!