From: us on
"Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i1aipl$1m0$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <i1af4l$nmh$1(a)fred.mathworks.com>...
> > "Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i18h5j$smb$1(a)fred.mathworks.com>...
> > > I've fit some data to a spline function. Now, I need to find all maximum and minimum points of this function. Does any one knows how to do it?
> > > Here follows a simple test code that I'm using.
> > > Thank you very much.
> > > Alex
> > >
> > > a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
> > > b=[1:size(a)];
> > > b = b(:);
> > > a = a(:);
> > > fo_ = fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
> > > ft_ = fittype('smoothingspline');
> > > cf_ = fit(b,a,ft_,fo_);
> > > h_ = plot(cf_,'fit',0.95); %% this line only plots the result
> >
> > no reason to discuss this as your code does not work...
> >
> > us
>
> Sorry. Now it works.
>
> a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
> b=[1:size(a,2)];
> b = b(:);
> a = a(:);
> fo_=fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
> ft_ = fittype('smoothingspline');
> cf_ = fit(b,a,ft_,fo_);
> h_ = plot(cf_,'fit',0.95);

ok...
now, why don't you use one of the many peak-finders available on the FEX(?)...

us
From: Alex Pereira on
"us " <us(a)neurol.unizh.ch> wrote in message <i1an85$q10$1(a)fred.mathworks.com>...
> "Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i1aipl$1m0$1(a)fred.mathworks.com>...
> > "us " <us(a)neurol.unizh.ch> wrote in message <i1af4l$nmh$1(a)fred.mathworks.com>...
> > > "Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i18h5j$smb$1(a)fred.mathworks.com>...
> > > > I've fit some data to a spline function. Now, I need to find all maximum and minimum points of this function. Does any one knows how to do it?
> > > > Here follows a simple test code that I'm using.
> > > > Thank you very much.
> > > > Alex
> > > >
> > > > a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
> > > > b=[1:size(a)];
> > > > b = b(:);
> > > > a = a(:);
> > > > fo_ = fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
> > > > ft_ = fittype('smoothingspline');
> > > > cf_ = fit(b,a,ft_,fo_);
> > > > h_ = plot(cf_,'fit',0.95); %% this line only plots the result
> > >
> > > no reason to discuss this as your code does not work...
> > >
> > > us
> >
> > Sorry. Now it works.
> >
> > a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
> > b=[1:size(a,2)];
> > b = b(:);
> > a = a(:);
> > fo_=fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
> > ft_ = fittype('smoothingspline');
> > cf_ = fit(b,a,ft_,fo_);
> > h_ = plot(cf_,'fit',0.95);
>
> ok...
> now, why don't you use one of the many peak-finders available on the FEX(?)...
>
> us

I'm right now following your suggestion and trying to find a peak finder.
Thank you very much.
Alex
From: Alex Pereira on
"Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i1b7fg$3jj$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <i1an85$q10$1(a)fred.mathworks.com>...
> > "Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i1aipl$1m0$1(a)fred.mathworks.com>...
> > > "us " <us(a)neurol.unizh.ch> wrote in message <i1af4l$nmh$1(a)fred.mathworks.com>...
> > > > "Alex Pereira" <alexlopespereira(a)gmail.com> wrote in message <i18h5j$smb$1(a)fred.mathworks.com>...
> > > > > I've fit some data to a spline function. Now, I need to find all maximum and minimum points of this function. Does any one knows how to do it?
> > > > > Here follows a simple test code that I'm using.
> > > > > Thank you very much.
> > > > > Alex
> > > > >
> > > > > a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
> > > > > b=[1:size(a)];
> > > > > b = b(:);
> > > > > a = a(:);
> > > > > fo_ = fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
> > > > > ft_ = fittype('smoothingspline');
> > > > > cf_ = fit(b,a,ft_,fo_);
> > > > > h_ = plot(cf_,'fit',0.95); %% this line only plots the result
> > > >
> > > > no reason to discuss this as your code does not work...
> > > >
> > > > us
> > >
> > > Sorry. Now it works.
> > >
> > > a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
> > > b=[1:size(a,2)];
> > > b = b(:);
> > > a = a(:);
> > > fo_=fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
> > > ft_ = fittype('smoothingspline');
> > > cf_ = fit(b,a,ft_,fo_);
> > > h_ = plot(cf_,'fit',0.95);
> >
> > ok...
> > now, why don't you use one of the many peak-finders available on the FEX(?)...
> >
> > us
>
> I'm right now following your suggestion and trying to find a peak finder.
> Thank you very much.
> Alex

I could not find any peak finder that find it in a spline function. Then I searched other ways. Here follows the solution I found.

a=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ];
b=[1:size(a,2)];
b = b(:);
a = a(:);
fo=fitoptions('method','SmoothingSpline','SmoothingParam',0.10000000000000000555);
ft = fittype('smoothingspline');
cf = fit(b,a,ft,fo);
h = plot(cf,'fit',0.95);
fx = differentiate(cf, b);
fx2=fx;
fx2(fx2>0)=1;
fx2(fx2<0)=0;
find(diff(fx2)~=0)

Thank you very much.
Alex
First  |  Prev  | 
Pages: 1 2 3
Prev: importing geometry to PDEtool
Next: help with the code