From: Matt J on
"Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3q3d$i90$1(a)fred.mathworks.com>...
> "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj3oer$2ft$1(a)fred.mathworks.com>...
> > "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3n5k$a8q$1(a)fred.mathworks.com>...
> >
> > > Now...how to input the conditions you kindly suggested to me?...:-)
> >
> > It seems lsqcurvefit cannot handle linear constraints, you should rather use lsqlin or quadprog.
> >
> > Bruno
> Ok...but here the problem is how to use the tool....
> Yes, lsqlin wants a different way of formalizing the fitting funtion...
> It should be of the form: C = [x.^2 x ones(size(x))]; and not as an anonymous function, but in any case...how to force the conditions on the derivative and on the positiveness of the functions itself?...
==================

This looks like it could help, if you set the knot spacing sufficiently large:

http://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling
From: Simone on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hj3vrk$scl$1(a)fred.mathworks.com>...
> "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3q3d$i90$1(a)fred.mathworks.com>...
> > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj3oer$2ft$1(a)fred.mathworks.com>...
> > > "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3n5k$a8q$1(a)fred.mathworks.com>...
> > >
> > > > Now...how to input the conditions you kindly suggested to me?...:-)
> > >
> > > It seems lsqcurvefit cannot handle linear constraints, you should rather use lsqlin or quadprog.
> > >
> > > Bruno
> > Ok...but here the problem is how to use the tool....
> > Yes, lsqlin wants a different way of formalizing the fitting funtion...
> > It should be of the form: C = [x.^2 x ones(size(x))]; and not as an anonymous function, but in any case...how to force the conditions on the derivative and on the positiveness of the functions itself?...
> ==================
>
> This looks like it could help, if you set the knot spacing sufficiently large:
>
> http://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling

Thanks!...
Even I would need a function and not a piecewise fit...in fact with your slmeval I could evaluate it...
I'm going to try...
Thank you
Simone
From: Bruno Luong on
"Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3q3d$i90$1(a)fred.mathworks.com>...
> "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj3oer$2ft$1(a)fred.mathworks.com>...
> > "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3n5k$a8q$1(a)fred.mathworks.com>...
> >
> > > Now...how to input the conditions you kindly suggested to me?...:-)
> >
> > It seems lsqcurvefit cannot handle linear constraints, you should rather use lsqlin or quadprog.
> >
> > Bruno
> Ok...but here the problem is how to use the tool....
> Yes, lsqlin wants a different way of formalizing the fitting funtion...
> It should be of the form: C = [x.^2 x ones(size(x))]; and not as an anonymous function, but in any case...how to force the conditions on the derivative and on the positiveness of the functions itself?...
> Could you help me suggesting the syntax?...:-)
> Thanks in advance
> Simone

Try this (I have not check it, just code blindly here):

C = [x.^2 x ones(size(x))];
d = y(:);
a = min(x); % left bound
b = max(x); % right bound
A = -[2*a 1 0; % <- f'(a) >= 0
2*b 1 0; % <- f'(b) >= 0
a.^2 a 1] % <- f(a) >= 0
b = [0; 0; 0];

p = lsqlin(C,d,A,b);

plot(x, y, '.', x, polyval(p,x))

Bruno
From: Matt J on
"Simone " <alfinalmefui(a)gmail.com> wrote in message <hj4328$mdm$1(a)fred.mathworks.com>...
> "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hj3vrk$scl$1(a)fred.mathworks.com>...
> > "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3q3d$i90$1(a)fred.mathworks.com>...
> > > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj3oer$2ft$1(a)fred.mathworks.com>...
> > > > "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3n5k$a8q$1(a)fred.mathworks.com>...
> > > >
> > > > > Now...how to input the conditions you kindly suggested to me?...:-)
> > > >
> > > > It seems lsqcurvefit cannot handle linear constraints, you should rather use lsqlin or quadprog.
> > > >
> > > > Bruno
> > > Ok...but here the problem is how to use the tool....
> > > Yes, lsqlin wants a different way of formalizing the fitting funtion...
> > > It should be of the form: C = [x.^2 x ones(size(x))]; and not as an anonymous function, but in any case...how to force the conditions on the derivative and on the positiveness of the functions itself?...
> > ==================
> >
> > This looks like it could help, if you set the knot spacing sufficiently large:
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling
>
> Thanks!...
===========

Just to be clear:


> Even I would need a function and not a piecewise fit...i
=================

You do understood though that, if the knots are widely enough spaced, the piecewise fit really consists of only 1 piece, right?

>n fact with your slmeval I could evaluate it...
==================

not mine.
From: Simone on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj44qg$ear$1(a)fred.mathworks.com>...
> "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3q3d$i90$1(a)fred.mathworks.com>...
> > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj3oer$2ft$1(a)fred.mathworks.com>...
> > > "Simone " <alfinalmefui(a)gmail.com> wrote in message <hj3n5k$a8q$1(a)fred.mathworks.com>...
> > >
> > > > Now...how to input the conditions you kindly suggested to me?...:-)
> > >
> > > It seems lsqcurvefit cannot handle linear constraints, you should rather use lsqlin or quadprog.
> > >
> > > Bruno
> > Ok...but here the problem is how to use the tool....
> > Yes, lsqlin wants a different way of formalizing the fitting funtion...
> > It should be of the form: C = [x.^2 x ones(size(x))]; and not as an anonymous function, but in any case...how to force the conditions on the derivative and on the positiveness of the functions itself?...
> > Could you help me suggesting the syntax?...:-)
> > Thanks in advance
> > Simone
>
> Try this (I have not check it, just code blindly here):
>
> C = [x.^2 x ones(size(x))];
> d = y(:);
> a = min(x); % left bound
> b = max(x); % right bound
> A = -[2*a 1 0; % <- f'(a) >= 0
> 2*b 1 0; % <- f'(b) >= 0
> a.^2 a 1] % <- f(a) >= 0
> b = [0; 0; 0];
>
> p = lsqlin(C,d,A,b);
>
> plot(x, y, '.', x, polyval(p,x))
>
> Bruno

Hi Bruno!...
thanks for the reply!...and sorry for the late of my answer...
Your suggestions made me understand how to use the function!...
Thank you...

The problem is that the second order polynomial does not fit very well (i thought it did but I was in error)...

Hence, I have to try with higher order polynomial...
Now the conditions for the first derivative are not enough...aren't them?
Do I have to force the second derivative to be positive in both extreme...do I?...

Thanks in advance
Simone
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: sort matrix rows
Next: Marching Cube outdated?