[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should interp1.m function allow jumps in X-values?
From: |
Ben Abbott |
Subject: |
Re: Should interp1.m function allow jumps in X-values? |
Date: |
Wed, 22 Aug 2012 08:33:57 -0400 |
On Aug 21, 2012, at 8:01 PM, Michael D Godfrey wrote:
> On 08/21/2012 07:50 PM, Ben Abbott wrote:
>> X = [ 2 1 3 2];
>> Y = [ 2 1 3 10];
>> [X, n] = sort (X, "descend")
>>
> Did you really mean to only sort X? It seems to
> me that both X and Y should be sorted using the same
> option. Does this work? I do not see how it could different
> than your option for -right or -left.
The reason for the difference is subtle (and sorry for not pointing it out
earlier). The sort() function does not change the order of the duplicate X
values. Thus, the continuity condition is not switched from right to left.
The flipup() function is used in interp1 to do that. Below I used the fliplr()
to ensure the proper continuity.
X = [ 2 1 3 2];
Y = [ 9 1 3 10];
% These are right-continuos (returns 10)
y1 = interp1 (X, Y, 2)
[~, n] = sort (X);
y2 = interp1 (X(n), Y(n), 2)
[~, n] = sort (X, "descend");
y3 = interp1 (X(n), Y(n), 2)
y4 = interp1 (X, Y, 2, "-right")
% These are left-continuous (returns 9)
[~, n] = sort (fliplr (X), "descend");
y5 = interp1 (X(n), fliplr(Y)(n), 2)
y6 = interp1 (X, Y, 2, "-left")
Ben
- Re: Should interp1.m function allow jumps in X-values?, (continued)
- Re: Should interp1.m function allow jumps in X-values?, Michael D Godfrey, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, vivek dogra, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Juan Pablo Carbajal, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Ben Abbott, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Ben Abbott, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Michael D Godfrey, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, vivek dogra, 2012/08/22
- Message not available
- Message not available
- Re: Should interp1.m function allow jumps in X-values?, Michael D Godfrey, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Ben Abbott, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Michael D Godfrey, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?,
Ben Abbott <=
- Re: Should interp1.m function allow jumps in X-values?, Michael D Godfrey, 2012/08/22
- Re: Should interp1.m function allow jumps in X-values?, Ben Abbott, 2012/08/22
- Re: Should interp1.m function allow jumps in X-values?, Ben Abbott, 2012/08/23
- Re: Should interp1.m function allow jumps in X-values?, Michael D Godfrey, 2012/08/23
- Re: Should interp1.m function allow jumps in X-values?, Martin Helm, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Juan Pablo Carbajal, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Ed Meyer, 2012/08/21
- Re: Should interp1.m function allow jumps in X-values?, Martin Helm, 2012/08/21