Info

此问题已关闭。 请重新打开它进行编辑或回答。

Matching rows in different matrices

1 次查看(过去 30 天)
Muneer
Muneer 2013-12-9
关闭: Azzi Abdelmalek 2013-12-9
I have a time array = [0 0.06 .12 .18 .24 ... 7684.3] which has a total of 128072 (128072x1) elements.
I have a separate matrix called timedata with time in the first column (has some repeated elements) and a data value in the second column. It looks like this: 0 0 0 0 .06 0 .12 0 .18 0 .24 0 ... ... 7684.3 0
Its dimensions are 128425x2 because it has some repeated elements (as you can see 0 is repeated twice because I combined two matrices together and then sorted them in ascending order). I want to use my time vector as a control and pick the values from timedata that match. So the first val in "time" is 0, take the whole row of "timedata" where the first column is 0. The second val in "time" is .06 so I want to take the row that matches in "timedata". This would give me the third row and skip the second. At the end of this process, I would have a matrix with the same number of rows as "time". Any ideas on how to do this? I tried using a for loop like this
for i = 1:length(time)
new(i) = timedata(time(i), i);
end
But I don't think I'm indexing correctly. Any help would be greatly appreciated. Thanks in advance.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by