Correlation between two differently sized data sets

조회 수: 13 (최근 30일)
Jan Wingens
Jan Wingens 2015년 10월 18일
댓글: Jan Wingens 2015년 10월 19일
Assume that I have solved a System with an ODE-Solver. The results [T1,Y1] (time and corresponding solution vector) I obtained for specific tolerances.
Now I have changed the tolerances and have [T2,Y2]. Although the time span for simulation remains the same these data sets have different lengths.
For example these lengths:
T1: 200x1, Y1: 200x3
T2: 500x1, Y2: 500x3
Now i can plot these sets easily for each component of Y into one plot, so I can see the differences. What I would like to do now is calculate the correlation coefficient to see how well these data sets match. My problem is this:
I can only correlate them, if the vectors of Y have the same length. So how do I expand the vector Y1 to match the size of Y2, obviously while keeping the same relation to the times T1 and T2 (which should then actually be the same)?
I tried interp() and resample(), but that does not work for me...
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 10월 18일
Please post your interp1() attempt.
Jan Wingens
Jan Wingens 2015년 10월 19일
So I have:
T1: 37544x1 and Y1: 37544x14
as well as
T2: 4684x1 and Y2: 4684x1
In order to bring, say the first component of Y2 to a length of 37544 I write:
NewY2_1=interp(Y2(:,1),r)
where r is the factor by which the sampling rate is increased. In my case it should be r=37544/4684=8.015....
However r must be an integer, so this doesn't work.
Then I found resample(): y = resample(x,p,q) resamples the input sequence, x, at p/q times the original sample rate. This would work in my case. But at the end of the sampling strange errors occur. Also it does not resample to my desired length of 7 seconds but to 7.51 or so seconds. I suppose that is beacuse: resample applies an antialiasing FIR lowpass filter to x and compensates for the delay introduced by the filter.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 19일
NewY2 = interp1(T2,Y2,T1);
  댓글 수: 1
Jan Wingens
Jan Wingens 2015년 10월 19일
Thank you very much, I did not realize that there was interp1(). I just read the entry about interp().

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by