I would like to linearly resample a matrix. For example if A = [0,0;5,10;10,20] I would like to resample it such that B = [0,0;1,2;2,4;3,6;4,8;5,10;6,12;7,14;8,16;9,18;10,20]
B =
0 0
1 2
2 4
3 6
4 8
5 10
6 12
7 14
8 16
9 18
10 20
I originally thought that this is what the resample function did, but upon further analysis I was wrong. Please keep in mind that I am doing this for large sensor files, files which contain data for weeks at 5 minute timesteps.
Thank you for any help

답변 (2개)

Chad Greene
Chad Greene 2016년 5월 4일

0 개 추천

A = [0,0;5,10;10,20];
B(:,1) = 1:10;
B(:,2) = interp1(A(:,1),A(:,2),B(:,1),'linear')
B =
1.00 2.00
2.00 4.00
3.00 6.00
4.00 8.00
5.00 10.00
6.00 12.00
7.00 14.00
8.00 16.00
9.00 18.00
10.00 20.00

댓글 수: 2

Justin Berquist
Justin Berquist 2016년 5월 4일
That was just an example, I need to do it for a scenario where A is a 2xn matrix and the values within are not known. How would I go about that?
Thank you
Chad Greene
Chad Greene 2016년 5월 4일
Which values are unknown?

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

Star Strider
Star Strider 2016년 5월 4일

0 개 추천

You can certainly use the resample function. You simply have to create a timeseries object from your data.

댓글 수: 3

Justin Berquist
Justin Berquist 2016년 5월 4일
A = xlsread('Canal5208RadiatorT_out.csv','','A:B'); C = length(A); A = resample(A,A(:,1):0.2:A(:,C));
What is wrong with this then? I just want my data to be linearly interpolated, adding 4 points inbetween every 2 original points.
Justin Berquist
Justin Berquist 2016년 5월 4일
When i simply do A = resample(A,5,1) my data is not linearly aligned
Star Strider
Star Strider 2016년 5월 4일
I would have to see your ‘Canal5208RadiatorT_out.csv’ file. If your data are regularly sampled (fixed sampling interval), linearly interpolating it is straightforward, using the linspace function, for instance, to generate the ‘query’ vector. If it’s not regularly-sampled, this becomes more difficult, because four points in every individual interval have to be created.

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

카테고리

질문:

2016년 5월 4일

댓글:

2016년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by