Interpolation is wrong?
6 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone!
I have a variable, 'wc_average' that I'd like to interpolate so it's the same size as another variable 'dep_cal2012'. Wc_average is about 78x1 and 'dep_cal2012' is about 977x1. The spacing between every point in wc_average is about every 10 minutes while the spacing between every measurement in dep_cal2012 is every nanosecond (there are about 7 measurements taken within the same second). I've tried interpolating wc_average with this code:
x=dep_cal2012; y=wc_average;
ix = linspace(1, numel(x), numel(y));
WC_interp = interp1(ix, y, 1:numel(x),'nearest'); WC_cap=WC_interp';
However, I've tried comparing the timeseries between the two and the interpolated one isn't right.
The code to run the figure:
figure(8787)
subplot(2,1,1)
plot(wcdate_av,wc_average,'-k')
xlabel('date')
title('OG')
subplot(2,1,2)
plot(cr_2012.datetime,WC_cap,'-k')
xlabel('date')
title('Interpolated')
What could be the reasoning behind the wrong interpolation? I've tried every method of interpolation and they all yield the same results.
0 件のコメント
回答 (2 件)
KSSV
2021 年 11 月 15 日
x=dep_cal2012; % 977x1
y=wc_average; % 78x1
ix = linspace(1, numel(y), numel(x));
WC_interp = interp1(1:numel(y), y,ix,'nearest');
WC_cap=WC_interp';
0 件のコメント
Sulaymon Eshkabilov
2021 年 11 月 15 日
編集済み: Sulaymon Eshkabilov
2021 年 11 月 15 日
Here is the corrected code:
x=dep_cal2012; y=wc_average;
ix = linspace(1, max(x), numel(y));
WC_interp = interp1(ix, y, x,'nearest'); WC_cap=WC_interp';
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!