Results 1 to 5 of 5

Math Help - Matlab - interp1 (linear/nearest)

  1. #1
    Junior Member
    Joined
    Apr 2009
    Posts
    45

    Matlab - interp1 (linear/nearest)

    Hi,

    Was wondering if anyone knows why when interpolate the following data (which is part of a larger matrix of data 14x22) that the NaN values remain:

    x = [0.4500; 0.6300; 0.9700; 2.2500; 4.4700; NaN; 2.4700; 3.2400; 5.5600; 6.1300; 6.5600; 6.9900; 7.3500; 7.6300; 7.7700]
    y = [0; 2.3469; 26.3453; 50.3483; 74.3486; 98.3481; 122.3492; 146.3461; 170.3467; 194.3469; 218.3486; 242.3467; 266.3469; 290.3500; 307.4056]
    t = [0; 24; 48; 72; 96; 120; 144; 168; 192; 216; 240; 264; 288; 312]

    z = interp1(x,y,t)

    But z is returned with NaNs. Using 'spline' removes the NaN but then this "over smooths" the data.

    Is there a way to interpolate between the NaN values?

    Thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Apr 2005
    Posts
    16,257
    Thanks
    1797

    Re: Matlab - interp1 (linear/nearest)

    "NaN" is short for "not a number".Typically it shows up in numeric calculations where the computed value would be too large to fit in the computer or calculator. It can be thought of as meaning "infinite" as, for example, 1 divided by a very very small number produces a huge quotient: 1/x, as x goes to 0, goes to infinity.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Apr 2009
    Posts
    45

    Re: Matlab - interp1 (linear/nearest)

    Thanks for the reply. I understand that the NaN is not a number. This was data imported from excel and I thought interp1 could be used to interpolate between the NaN in the data to infill the missing data.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Apr 2013
    From
    Bangladesh
    Posts
    2

    Re: Matlab - interp1 (linear/nearest)

    these concept is very helpful for me thanks to all
    all the best
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Apr 2012
    From
    Erewhon
    Posts
    200
    Thanks
    131

    Re: Matlab - interp1 (linear/nearest)

    Quote Originally Posted by rem88 View Post
    Thanks for the reply. I understand that the NaN is not a number. This was data imported from excel and I thought interp1 could be used to interpolate between the NaN in the data to infill the missing data.
    Since NaN does not distinguish between +/- large and out of valid range for a double you cannot do any kind of fudged interpolation between a double and a NaN.

    Also if the NaN corresponds to a singularity the function may well change sign there and you would never know ...

    .
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. linear equations in matlab
    Posted in the Math Software Forum
    Replies: 8
    Last Post: December 7th 2009, 11:32 AM
  2. Matlab and linear algebra
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 23rd 2009, 12:13 AM
  3. MATLAB linear programming
    Posted in the Math Software Forum
    Replies: 0
    Last Post: January 31st 2009, 03:02 PM
  4. Linear Algebra with MATLAB
    Posted in the Math Software Forum
    Replies: 0
    Last Post: December 7th 2008, 07:29 PM
  5. Linear equations and matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: January 28th 2008, 12:40 AM

Search Tags


/mathhelpforum @mathhelpforum