Spline interpolation in matlab

4 visualizaciones (últimos 30 días)
Rachel Chung
Rachel Chung el 25 de Mzo. de 2015
Respondida: dpb el 25 de Mzo. de 2015
I have the following:
x = 1:365;
y = T;
xx = missing;
yy = interp1(x,y,xx,'spline')
I have data `T`, which is 365 days of data, and `missing` is a vector containing the days on which the data is faulty. I need to generate estimated values at the missing days. However, when I use the above syntax, it returned a vector of all the same value. I made some changes, got an error, deleted them, and now with the same syntax I'm getting the error on line 4:
You can not subscript a table using only one subscript. Table subscripting
requires both row and variable subscripts.
What am I doing wrong?
  2 comentarios
Christiaan
Christiaan el 25 de Mzo. de 2015
Dear Rachel,
Could you send us the mat-file of 'T' and 'missing'? A small example, how the interp1 function works, I have posted below for you.
clc; clear all; close all;
x = 1:365;
y = sin(x);
xx = [1 3 4];
yy = interp1(x,y,xx,'spline')
Kind regards, Christiaan
Rachel Chung
Rachel Chung el 25 de Mzo. de 2015
here's the file!

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 25 de Mzo. de 2015
Your T vector has zero-valued entries for the missing locations and so there is a data value at that day and therefore interp1 returns that value (0) instead of an interpolated value.
T(missing)=[]; % remove the missing locations
t=1:365; t(missing)=[]; % the correlating full day vector
yy=interp1(t,T,missing,'spline')

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by