time align two files
1 次查看(过去 30 天)
显示 更早的评论
I have two CSV files that are not equal sizes. for one of the files,I want to obtain all values for when column two is only equal to one. I already did this, the code for this is:
P = N(N(:,2)==1,:);
Now that I have all the data associated with column 2 when it equals to 1, I want this file to line up with another file. So where ever the second column is = to 1, i want the second file to only show values that are at the same position.
my code for this is:
Val = find(isnan(P));
P(Val) = [];
M(Val) = [];
So there arent any nan values in the data set but this does what I want it to do. P is the values associated with column 2 when it = to 1 and M is the second file.
2 个评论
Guillaume
2020-3-11
"there arent any nan values in the data set but this does what I want it to do"
If there aren't any nan values then your code does nothing at all.
I'm not entirely sure what you mean by "line up". Can you clarify with an example?
However, just going by the title of your question if you want to match the times of two different files, then importing them as timetables and then synchronize the two. Possibly, this is done with just 3 lines of code.
采纳的回答
Guillaume
2020-3-11
In your example, what you're asking is simply:
M(P(:, 2) ~= 1, :) = [] %remove all rows of M for which the corresponding row of P is not 1.
How this translates to your real use case, I'm not too sure, particularly as you say that M and P haven't got the same number of rows.
11 个评论
Guillaume
2020-3-18
What do you mean by 'rows that are extra'?
Again, having a concrete example of what you actually want would help.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!