Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: cubic spline problem
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
dwi

Posts: 17
Registered: 10/18/12
cubic spline problem
Posted: Jan 12, 2013 12:18 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am using cubic spline to connect the maxima and another cubic spline to connect the minima of a signal thus creating two "envelopes" that encompass the signal. Then I compute the average of the two envelopes and subtract it from the signal. When I do this many times the cubic spline creates a problem at the beginning of the signal like adding noise only to a specific region and the first few values go up to 10^22! When comparing it with this, the rest of the signal seems as zero. My code works like the Huang method analyzing a signal to its imfs if anyone is familiar with it. Is there any way to "correct" the cubic spline so as to compute correct means and eliminate the problem? This is the part of my code with the cubic spline (the problem occurs on the 3d sifting):

plot(DATA);
localmaxima=imregionalmax(DATA);
plithosmaxima=sum(localmaxima);
for i=1:length(localmaxima)
if localmaxima(i)==1
maxima1(i)=DATA(i);
end
end
for i=1:length(maxima1)
dataxx(i)=i;
end
for i=1:length(dataxx)
if (maxima1(i)>0)|(maxima1(i)<0)
maxima(i)=maxima1(i);
datax(i)=dataxx(i);
end
end
maxima=maxima(maxima~=0);
datax=datax(datax~=0);
localminima=imregionalmin(DATA);
plithosminima=sum(localminima);
for i=1:length(localminima)
if localminima(i)==1
minima1(i)=DATA(i);
end
end
for i=1:length(minima1)
dataxxx(i)=i;
end
for i=1:length(dataxxx)
if (minima1(i)>0)|(minima1(i)<0)
minima(i)=minima1(i);
datasx(i)=dataxxx(i);
end
end
minima=minima(minima~=0);
datasx=datasx(datasx~=0);
if (plithosmaxima>1)&(plithosminima>1)
cs=spline(datax,[maxima(1) maxima maxima(end)]);
xx=linspace(min(datax),max(datax),length(DATA));
upenvelope=ppval(cs,xx);
hold on
plot(datax,maxima,'r*',xx,upenvelope,'r:');
css=spline(datasx,[minima(1) minima minima(end)]);
xxx=linspace(min(datasx),max(datasx),length(DATA));
downenvelope=ppval(css,xxx);
hold on
plot(datasx,minima,'r*',xxx,downenvelope,'r:');
mesitimi=(upenvelope+downenvelope)/2;
hold on
plot(mesitimi,'g-');
h=DATA-mesitimi';
end



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.