Plotting and calculating difference
2 次查看(过去 30 天)
显示 更早的评论
I have 2 matrix containing data of timestamps, 1 X Nth matrix I loaded them into the workspace and i want to plot the data on x axis and in the same figure. their size of matrix are different.
load('observations.mat');
load('control-times.mat');
index=880;
timestamp = ctrl_times(:,index:end);
obser_time = observation_times(:,1:end);
fig=figure;
hold on; axis equal;
plot(timestamp(1,:),'b*');
After plotting, how do i calculate the difference between data of the 2 matrices?
For example 1st data of timestamp - 1318496774.36108
however obser_time data starts from column 140 - 1318496774.90708
I would require looping if i am not wrong.
Thanks in advance.
6 个评论
Walter Roberson
2012-1-13
Okay, so now please expand on what you mean by obser_time data starts from column 140 ? Do you mean the first 139 columns are NaN, or do you mean that column 1 of obser_time logically corresponds to column 140 of timestamp ?
采纳的回答
Walter Roberson
2012-1-13
Hours to find out what you really wanted to do. Less than a minute to solve once that was known.
plot(timestamp, 'b*', obser_time, 'r+'); %your plot
padtimestamp = [0 timestamp inf];
[counts, binnums] = histc(obser_time, padtimestamp);
timestampdiff = obser_time - padtimestamp(binnums); %compared
4 个评论
Walter Roberson
2012-1-17
nextdiff = padtimestamp(binnums+1) - obser_time;
Note if there is an observ_time which is exactly the same or greater than the largest timestamp, then this nextdiff time will be infinity.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!