Interpolation is wrong?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
KSSV
le 15 Nov 2021
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 commentaires
Sulaymon Eshkabilov
le 15 Nov 2021
Modifié(e) : Sulaymon Eshkabilov
le 15 Nov 2021
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 commentaires
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!