How can I code for cosine fit ?

1 回表示 (過去 30 日間)
RS
RS 2013 年 3 月 24 日
How can I write code for smooth cosine fit for given data and find residual ?
  2 件のコメント
Jan
Jan 2013 年 3 月 25 日
Please post, what you have done so far and ask a specific question.
RS
RS 2013 年 4 月 2 日
I have this data as X data column
1. [624.0397 743.4188 641.3096 764.2928 698.1912 832.8933 799.6397 767.3729 735.1792 703.093 671.0012 638.9143 605.9839 668.0182 0 0 0 0 0 0]
Y column
1. [8.071650105 8.144216751 8.177926597 8.171846343 8.073710465 7.999249364 8.00676841 8.064808175 8.061246346 8.064100517 8.041524691 8.045426565 8.068412239 8.225694432 0 0 0 0 0 0]
As the same way I am having data set for third column having x data set and again fourth column I am having y data set as so on upto 520, and also all having same number of element mean column having same number of element and some zero values also.
and want to smooth, cosine fit and want to compute residual for this I have tried
x=[];
y=[];
for j=1:519
x=AC(:,j+1);
y=AC(:,j);
xx=find(y);
xxx=max(xx);
y1=smooth(x,y(1:xxx),'moving',5);
fitted_curve=cos(x);
end
errors are ??? Error using ==> smooth at 131 X and Y must be the same length.
So how can I fit in cosine and compute residual of fit.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2013 年 3 月 25 日
Any signal is composed of lots of cosines - that's basically what the Fourier transform (spectrum) is. It's the strength (weight) of all the cosines that can go into building up your signal. Maybe just take the Fourier Transform and look for the highest frequency to determine the frequency of cosine that is contributing most to your signal. Once you know the frequency, just construct a signal and subtract it from your original signal, etc.
  4 件のコメント
RS
RS 2013 年 3 月 29 日
編集済み: RS 2013 年 4 月 1 日
I have X and Y data and want to smooth, cosine fit and then find the residual, in Y there is some zero values also?
I have this data as X data column
[624.0397 743.4188 641.3096 764.2928 698.1912 832.8933 799.6397 767.3729 735.1792 703.093 671.0012 638.9143 605.9839 668.0182 0 0 0 0 0 0] Y column
[8.071650105 8.144216751 8.177926597 8.171846343 8.073710465 7.999249364 8.00676841 8.064808175 8.061246346 8.064100517 8.041524691 8.045426565 8.068412239 8.225694432 0 0 0 0 0 0] and want to smooth, cosine fit and want to compute residual for this I have tried
x=[];
y=[];
for j=1:519
x=AC(:,j+1);
y=AC(:,j);
xx=find(y);
xxx=max(xx);
y1=smooth(x,y(1:xxx),'moving',5);
fitted_curve=cos(x);
end
errors are ??? Error using ==> smooth at 131 X and Y must be the same length.
So how can I fit in cosine and compute residual of fit.
RS
RS 2013 年 4 月 2 日
actually there is data set in which first column represents x data and second column represent y data, third column represent x data again and fourth column represents y data and so on. all having fix number of element then again it is showing same error why so ?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by