Thread Subject: data fitting / data analysis - spline?

Subject: data fitting / data analysis - spline?

From: Mario

Date: 2 Sep, 2008 20:20:17

Message: 1 of 5

Hi!
I'm analyzing a list of x-y values,
http://www.geocities.com/mariopwr/data.png
http://www.geocities.com/mariopwr/dataxy.zip ,and i'm
wondering if anybody can suggest me a good way to fit a
curve on these points.
I tried using the spline toolbox and I found a good (in my
opinion) fit using the least square approximation with order
14 (http://www.geocities.com/mariopwr/spline.png). Do you
think it's a good approximation or should i try a different
method?

Anyway, after that i'd want to extract a few information
from this graph like amplitude and width of each wave. Any
suggestion?

Thank you for your help!

Mario

Subject: data fitting / data analysis - spline?

From: Miroslav Balda

Date: 4 Sep, 2008 21:01:25

Message: 2 of 5

"Mario " <nospam@yahoo.com> wrote in message
<g9k761$d2h$1@fred.mathworks.com>...
SNIP

Hi Mario,

Nobody answered yet, newertheless there is a solution in
Fourier transform and a filtration in frequency domain. Test
this code:

load dataxy; % the downloaded data - signal
x = xy(:,1);
y = xy(:,2);
m = length(x);
A = [ones(m,1),x];
c = A\y % coeffitients of best linear fit
yc = y - A*c; % detrended signal
Yc = fft(yc); % DFT of the signal
n = 20; % chosen number of low frequency components
Yf = [Yc(1:n); zeros(m-2*n,1); Yc(end-n+1:end)];% filt. DFT
yf = real(ifft(Yf)); % filtered signal
yr = yf + A*c; % regressed y
plot(x,y, x,yr,'r')
grid

The bigger is n the better approximation you get.
Hope this helps.

Mira

Subject: data fitting / data analysis - spline?

From: Carlos Adrian Vargas Aguilera

Date: 10 Sep, 2008 02:12:02

Message: 3 of 5

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <g9pib5$je2$1@fred.mathworks.com>...
> "Mario " <nospam@yahoo.com> wrote in message
> <g9k761$d2h$1@fred.mathworks.com>...
> SNIP
>
> Hi Mario,
>
> Nobody answered yet, newertheless there is a solution in
> Fourier transform and a filtration in frequency domain. Test
> this code:
>
> load dataxy; % the downloaded data - signal
> x = xy(:,1);
> y = xy(:,2);
> m = length(x);
> A = [ones(m,1),x];
> c = A\y % coeffitients of best linear fit
> yc = y - A*c; % detrended signal
> Yc = fft(yc); % DFT of the signal
> n = 20; % chosen number of low frequency components
> Yf = [Yc(1:n); zeros(m-2*n,1); Yc(end-n+1:end)];% filt. DFT
> yf = real(ifft(Yf)); % filtered signal
> yr = yf + A*c; % regressed y
> plot(x,y, x,yr,'r')
> grid
>
> The bigger is n the better approximation you get.
> Hope this helps.
>
> Mira
>


This is an ideal filter, but is the worst way to do a filtering. You are applying a weighting/multiplication rectangular window in frequency domain, which is a smoothing/convolution SINC window in the time domain with huge sidelobes and Gibb's phenomena.

Take a look to WINSINC here at the FileExchange:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8574

Carlos Vargas

Subject: data fitting / data analysis - spline?

From: Mario

Date: 19 Sep, 2008 19:33:02

Message: 4 of 5

so what do you guys suggest to filter my data in the best way?
I'd like to keep the peaks at approximately 5-15-35-50-70-85 an so on (in picture http://www.geocities.com/mariopwr/data.png ) and then fit a spline on the filtered signal.

Thank you for your help!
Regards,

Mario

Subject: data fitting / data analysis - spline?

From: rych

Date: 23 Sep, 2008 09:19:57

Message: 5 of 5

On Sep 10, 3:12 am, "Carlos Adrian Vargas Aguilera"
<nubeobsc...@hotmail.com> wrote:
>
> > load dataxy; % the downloaded data - signal
> > x = xy(:,1);
> > y = xy(:,2);
> > m = length(x);
> > A = [ones(m,1),x];
> > c = A\y % coeffitients of best linear fit
> > yc = y - A*c; % detrended signal
> > Yc = fft(yc); % DFT of the signal
> > n = 20; % chosen number of low frequency components
> > Yf = [Yc(1:n); zeros(m-2*n,1); Yc(end-n+1:end)];% filt. DFT
> > yf = real(ifft(Yf)); % filtered signal
> > yr = yf + A*c; % regressed y
> > plot(x,y, x,yr,'r')
> > grid
>
> This is an ideal filter, but is the worst way to do a filtering. You are applying a weighting/multiplication rectangular window in frequency domain, which is a smoothing/convolution SINC window in the time domain with huge sidelobes and Gibb's phenomena.
>
> Take a look to WINSINC here at the FileExchange:http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objec...


Carlos,
Could you elaborate a little more on how to do the same "detrending"
using winsinc and why it is better?
Igor

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
filter Mario 19 Sep, 2008 15:35:06
ifft Miroslav Balda 4 Sep, 2008 17:05:05
fft Miroslav Balda 4 Sep, 2008 17:05:05
rssFeed for this Thread

Contact us at files@mathworks.com