From: Matt J on
"Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hov381$j7t$1(a)fred.mathworks.com>...

> > And why, as suggested in an earlier post, don't you just generate LSF data on a wider interval? Then you wouldn't have to extrapolate at all.
>
> I don't understand what you mean.
> If the size of the LSF support is 1X15 I need it on 2D domain with support of 15X15.
===============

But why is the size of LSF constrained to be 1x15? Where does LSF and its domain size come from? In your guassian example, LSF is given by an analytical formula and its domain size is chosen by you. If LSF will be given by an analytical formula in general, why not just use the analytical formula to generate a larger LSF array, e.g. of size 1x30? That would guarantee that all points in your 2D domain will be obtained by interpolation, not extrapolation.

If you really are stuck with an LSF formula defined only on a given truncated domain, this is really just a 1D extrapolation problem. In that case, it still seems to me that the SLM tool in the file exchange should be able to help you. Just zero-pad LSF and perform a fit to its zero-padded tails

Tail=[LSF(end), 0 0 0 0 0 ,...]


but using the tool's options to constrain the fit to be monotonic, etc...
From: Bruno Luong on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hovcce$7f0$1(a)fred.mathworks.com>...

>
> Tail=[LSF(end), 0 0 0 0 0 ,...]
>

I would avoid padding too many 0s because it will introduce a bias the interpolation data. Just concatenate a single 0 far away should be fine.

Bruno
From: Royi Avital on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hovdv3$11f$1(a)fred.mathworks.com>...
> "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hovcce$7f0$1(a)fred.mathworks.com>...
>
> >
> > Tail=[LSF(end), 0 0 0 0 0 ,...]
> >
>
> I would avoid padding too many 0s because it will introduce a bias the interpolation data. Just concatenate a single 0 far away should be fine.
>
> Bruno

The problem is I couldn't find how to use SLM the way I need.

Could anyone experienced with it help me with the syntax?
Look at the original post, all I need is to interpolate and extrapolate over the vector 'r' assuming Monotonic Decreasing and Non Negative assumptions for the extrapolation.

Thanks.
From: Bruno Luong on
Well I don't know LMS (do not own the toolbox), but a similar tool called BSFK in FEX http://www.mathworks.com/matlabcentral/fileexchange/25872 can do the same task asked here:

% Data
r = (-7:7);
sigma = 3;
PSF = exp(-0.5*(r/sigma).^2);

% Pad 0 far-away
r = [-15 r 15];
PSF = [0 PSF 0];

% Number of subintervals
n = length(r)-1;
% Constraints derivative>0 (monotonic) at two ends
lod = -inf(1,n); lod(1) = 0;
upd = +inf(1,n); upd(end) = 0;
shape = struct('p', 1, ...
'lo', lod, ...
'up', upd);
opt = struct('KnotRemoval','none', ...
'shape', shape);
% Fit with BSFK http://www.mathworks.com/matlabcentral/fileexchange/25872
pp = BSFK(r, PSF, [], n, [], opt);

% Graphic check
ri = linspace(min(r),max(r),257);
fi = ppval(pp,ri);
subplot(2,1,1);
plot(r,PSF,'ro',ri,fi,'b');
[X Y] = meshgrid(r,r);
R2D = sqrt(X.^2 + Y.^2);
F = ppval(pp, R2D);
fi = ppval(pp,ri);
subplot(2,1,2);
surf(X, Y, F)

% Bruno
From: Bruno Luong on
Sorry, there is few problem with my code previously, use this one.

% Data
r = (-7:7);
sigma = 3;
PSF = exp(-0.5*(r/sigma).^2);

% Pad 0
r = [-15 r 15];
PSF = [0 PSF 0];

% Number of subinterval
n = length(r)+1;
% Constraints derivative>0 at two ends
lod = -inf(1,n); lod(1) = 0;
upd = +inf(1,n); upd(end) = 0;
shape = struct('p', 1, ...
'lo', lod, ...
'up', upd);
opt = struct('KnotRemoval','none', ...
'shape', shape, ...
'lambda', 1e-6, ...
'regmethod', 'discrete');
% Fit with BSFK
% http://www.mathworks.com/matlabcentral/fileexchange/25872
pp = BSFK(r, PSF, [], [1 n-2 1], r([2 end-1]), opt);

% Graphic check
ri = linspace(min(r),max(r),257);
fi = ppval(pp,ri);
subplot(2,1,1);
plot(r,PSF,'ro',ri,fi,'b');
[X Y] = meshgrid(-7:7,-7:7);
R2D = sqrt(X.^2 + Y.^2);
F = ppval(pp, R2D);
subplot(2,1,2);
surf(X, Y, F)