Rank: 1407 based on 45 downloads (last 30 days) and 1 file submitted
photo

E. Rodriguez

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by E.
Updated   File Tags Downloads
(last 30 days)
Comments Rating
01 Dec 2005 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez gaps, gap, interpolation, interpolate, nans, outliers 45 7
  • 5.0
5.0 | 6 ratings
Comments and Ratings on E.'s Files View all
Updated File Comment by Comments Rating
21 Feb 2010 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez Hegarty, Tina

Thank you so much. I've spent so long trying to find a way to do exactly this! Great. :)

27 Feb 2009 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez D, David

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear
clc

% Test
Matrice= [ 99 2 3 0 6;
    4 5 99 0 0;
    7 0 8 99 NaN]
% Matrice bidon pour voir position index
B=[1:1:15];
Z=reshape (B, 3, 5)
% Fin test

% Détection des cas recherchés
Where_NaN= isnan(Matrice);
idx_NaN= find (Where_NaN==1);
idx_0_99= find (Matrice==0 | Matrice== 99);

% Création d'une liste unique d'index des cas recherchés
% Noter que je fais la transposée de idx_0_99 car c'est une colonne de vals
% donc pour la concatenation je dois la mettre en ligne pour aller avec idx_NaN
Lst_NaN_0_99 = [idx_NaN idx_0_99.']

% Remplacement des valeurs par moyenne des valeurs qui entoure position.
% 2 cas particuliers: premières et dernières positions dans les colonnes.
% Les if sont là pour les détecter. Si 1ere position dans colonne, nouvelle
% valeur égale à valeur suivante. Si dernière position, valeur égale à
% valeur précédente.

% Détection format matrice
[lignes, colonnes]= size (Matrice);

% Cas classique (calcul moyenne)
idx_PosiIn= find (rem(Lst_NaN_0_99(:),lignes)~=0 & rem(Lst_NaN_0_99(:),lignes)~=1);
% Calculer si pas de cas non voulus côte à côte
if (Matrice (idx_PosiIn - 1)~= idx_PosiIn(:) & Matrice (idx_PosiIn + 1)~= idx_PosiIn(:))
Matrice (idx_PosiIn)= (Matrice (idx_PosiIn - 1) + Matrice (idx_PosiIn + 1))/2;
end

% Position en haut de colonne
idx_PosiUn= find (rem(Lst_NaN_0_99(:),lignes)==1);
% Calculer si pas de cas non voulus côte à côte
if Matrice (idx_PosiUn + 1)~= idx_PosiUn(:)
Matrice (idx_PosiUn)= Matrice (idx_PosiUn + 1);
end

% Position en bas de colonne
idx_PosiLast= find (rem(Lst_NaN_0_99(:),lignes)==0);
% Calculer si pas de cas non voulus côte à côte
if Matrice (idx_PosiLast - 1)~= idx_PosiLast(:)
Matrice (idx_PosiLast)= Matrice (idx_PosiLast - 1);
end
it's not working can, someone help me

20 Jan 2009 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez Deepak

Thanks! We need a N-D version of this too.

13 Oct 2008 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez Murans, Girts
30 Jun 2008 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez Vargas Aguilera, Carlos Adrian

Je je, nice little function, which I rader use as a script, but anyway. You should explain in the help that data should be a time series (i.e. equally spaced), you can use 'extrap' to interpolate edges, and use isnan only one time, and set the method as an optional function, use griddatan for N-dimensional array in order to make your function more interesting and is a nice test:

method = 'cubic';
extrap = {'extrap'};
T = reshape(1:length(X),size(X));
inan = isnan(X);
X(inan) = interp1(T(~inan),X(~inan),T(inan),method,extrap{:});

Anyway, good luck

Top Tags Applied by E.
gap, gaps, holes, interpolate, interpolation
Files Tagged by E.
Updated   File Tags Downloads
(last 30 days)
Comments Rating
01 Dec 2005 naninterp One dimensional Interpolation over NaNs. Author: E. Rodriguez gaps, gap, interpolation, interpolate, nans, outliers 45 7
  • 5.0
5.0 | 6 ratings

Contact us at files@mathworks.com