How do I compare two data sets of unequal length?
이전 댓글 표시
I have two sets of data, taken on different days, from the same sensor. The temperature was swept from 26C to -30C to 80C and back to 26C. The sensor was read periodically during the temperature sweep. The data sets consist of a temperature column, and another column representing the sensor readings. I would like to take a difference between the two sets of sensor readings, generating another data set having a column of temperatures, and a column of differences between the two original sets of sensor readings. If each data set had exactly the same vector of temperatures, I could just subtract one vector of sensor readings from the other. However, the temperature vectors do not contain exactly the same temperatures, and they don't even have the same number of elements. I would like to interpolate one set of temperatures and sensor readings to match the temperatures of the other, so I have two data sets of the same size, at the same temperatures. One complicating factor is that, due to sensor hysteresis with respect to temperature, the sensor readings are different on the downward temperature ramps from those on the upward temperature ramp. Therefore I can't sort the data on temperature, because that would mix the upward and downward ramps. If I could sort the data on temperature, I could use timeseries objects, with temperature in place of time. However, that won't work in this case.
댓글 수: 8
Adam Danz
2018년 8월 8일
A sample of your data would be helpful to visualize the problem.
DH
2018년 8월 8일
Adam Danz
2018년 8월 8일
What is 'Sensory Data'?
Also, how are you going to pair the two temperature vectors? Are you pairing them by time-of-day? If so, where's the time data?
DH
2018년 8월 8일
I think I understand your problem now (sensorY was a typo). I'll think about it. In the meantime, here are @DH's data in case anyone else is thinking about this. The red and blue are the two data sets and you can see the lag in temperature and the sensor between the two data sets.

Adam Danz
2018년 8월 8일
...this is a tough one. You can't use interp1() because the first input is required to be monotonic without duplicates which your data isn't. Even if you sort by temperature and store the sorted index values, you still have duplicates. What is the final goal here? I know you want to measure the difference between the sensors at the same temperature. But you have duplicate measures within (nearly) the same temperature. For example, your temperature data passes through 0 twice. Can you use the average of those 2 sensor measures for the temp=0 data point?
DH
2018년 8월 9일
DH
2018년 8월 9일
채택된 답변
추가 답변 (2개)
Yuvaraj Venkataswamy
2018년 8월 8일
0 개 추천
댓글 수: 2
Adam Danz
2018년 8월 8일
Yeah, this method won't work.
Yuvaraj Venkataswamy
2018년 8월 8일
if true
id = ismember(dataset1', dataset2', 'rows');
X = 1:size(dataset1, 2);
Y = X(id);
end
댓글 수: 1
Adam Danz
2018년 8월 8일
This method won't work on your current data, either.
카테고리
도움말 센터 및 File Exchange에서 Resampling Techniques에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!