help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spline with NaNs


From: James Sherman Jr.
Subject: Re: spline with NaNs
Date: Mon, 17 May 2010 11:00:22 -0400

Well, as a quick hack, you could do something like:

valid_indices = ~isnan(param.two);
P = spline(param.one(valid_indices), param.two(valid_indices));

In fact, my guess is that this is what Matlab does at the beginning of its code, though I don't know for sure.

On Mon, May 17, 2010 at 10:42 AM, mallet <address@hidden> wrote:

Hello,
I want to use spline with data containing a NaN value. I Matlab i got a
«Warning: all data points with NaN in their value will be ignored.» , in
Octave: nothing.
But results aren’t same!

In Octave result is something like:
P =
1.0e+04  *

       NaN      NaN      NaN  1.04957
       NaN      NaN      NaN  1.33682
       NaN      NaN      NaN  1.31066
       NaN      NaN      NaN  0.89316
       NaN      NaN      NaN  1.41084
       NaN      NaN      NaN  0.55912
       NaN      NaN      NaN  0.60132
       NaN      NaN      NaN  0.48378
       NaN      NaN      NaN  0.35128
       NaN      NaN      NaN  0.34070
       NaN      NaN      NaN  0.21421
       NaN      NaN      NaN  0.24062
etc.

And in Matlab, like:
P =
1.0e+04  *

   -0.13693  0.25408  0.17010  1.04957
   -0.13693  -0.15670  0.26747  1.33682
   0.60669  -0.56748  -0.45671  1.31066
   -0.96328  1.25258  0.22839  0.89316
   0.94185  -1.63727  -0.15630  1.41084
   -0.54077  1.18827  -0.60530  0.55912
   0.16757  -0.43404  0.14893  0.60132
   0.01527  0.06867  -0.21644  0.48378
   -0.09176  0.11448  -0.03330  0.35128
   0.11394  -0.16080  -0.07962  0.34070
   -0.09522  0.18103  -0.05940  0.21421
etc.


Command: spline (param.one,param.two);

With:

param.two =

 1.0e+04  *

 1.04957
 1.33682
 1.31066
 0.89316
 1.41084
 0.55912
 0.60132
 0.48378
 0.35128
 0.34070
 0.21421
 0.24062
 0.20902
 0.19097
 0.09576
 0.12853
 0.11706
 0.08552
 0.07094
 0.06900
 0.03823
 0.06705
 0.06800
 0.05187
 0.02961
 0.03719
 0.02631
 0.02686
 0.02365
 0.03510
     NaN
 0.01845
 0.01549
 0.01141
 0.00845
 0.00797
 0.00827
 0.00686
 0.00871
 0.00825
 0.00759
 0.01125
 0.01728
 0.00418
 0.01619
 0.00400
 0.00292
 0.00426
 0.00294
 0.02139
 0.00483
 0.00364
 0.00200
 0.00268
 0.00426
 0.00194
 0.00182
 0.01132
 0.00552
 0.00323
 0.01064
 0.00196
 0.00282
 0.00789
 0.00755
 0.00232
 0.00221
 0.00180
 0.00135
 0.00387
 0.00737
 0.00214
 0.00117
 0.00193
 0.00126
 0.00189
 0.00240
 0.00273
 0.00199
 0.00212
 0.00139
 0.00179
 0.00665
 0.00182
 0.00084
 0.00117
 0.00075
 0.00071
 0.00062
 0.00093
 0.00079
 0.00182

param.one
ans =

       0
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91


--
View this message in context: http://octave.1599824.n4.nabble.com/spline-with-NaNs-tp2219744p2219744.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

[Prev in Thread] Current Thread [Next in Thread]