remove noise from data by polynomial fitting

Hi everyone, I want to remove noise from my data and for that I want to fit a polynomial. Can anyone plz tell me how can we remove noise in matlab?
Thanks

1 件のコメント

Matlabuser
Matlabuser 2014 年 10 月 27 日
I have a time series of temperature and I want to fit a polynomial of this kind T=A (log t)+B (log t)^2+ .......... so on

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

 採用された回答

Image Analyst
Image Analyst 2014 年 10 月 28 日

0 投票

x = log(t);
coefficients = polyfit(x, T, 1);
See full demo (with a different equation) attached.

4 件のコメント

Matlabuser
Matlabuser 2014 年 10 月 28 日
編集済み: Image Analyst 2014 年 10 月 28 日
hi, Thank You I tried to use this command, but I am not getting anything good.It inverted my time series. I did like this:
load T;
t=[10:10:2500];
x=log(t);
coff= polyfit(x,T,1);
A1=polyval(Coeff,x);
plot(x,A1);
I am new to Matlab, So I am not able to understand this problem
Image Analyst
Image Analyst 2014 年 10 月 28 日
編集済み: Image Analyst 2014 年 10 月 28 日
You need to get t back from x by using exp() and then plot(t, A1, 'bo-'); Or better yet, make more points like I did in my demo so you can see the shape of the equation.
Matlabuser
Matlabuser 2014 年 10 月 28 日
I got It. One more thing I want to know that now this plot is plot is in between values of T obtained after logarithmic fitting and time.
Thank you so much !!!
Image Analyst
Image Analyst 2014 年 10 月 28 日
You need to give more interpolation points, like
% Setup:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
t=[10:100:2500];
% T=A (log t)+B (log t)^2
A = 5;
B = 3;
T = A * log(t) + B * log(t).^2
% Add noise so it's not so perfect.
T = T + 50*rand(1, length(T));
% Plot training data
plot(t, T, 'bo', 'LineWidth', 2);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.1 1 .75]);
hold on;
%--------------------------------------------------------------
% Find polynomial
x=log(t); % Transform t so it's a lienar least squares situation.
% Now T = A*x + B*x^2 and we can fit a second order polynomial.
coefficients = polyfit(x,T,2)
% Interpolate additional points for a total of 300.
extra_x = linspace(x(1), x(end), 300);
fittedData = polyval(coefficients, extra_x);
% But we want to plot against t, not x so we need to recover t from extra_x.
extra_t = exp(extra_x);
plot(extra_t, fittedData, 'r*-', 'LineWidth', 2);
xlabel('t', 'FontSize', fontSize);
ylabel('T', 'FontSize', fontSize);
title('T vs. t', 'FontSize', fontSize);
legend('Training Data', 'Fit');

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

その他の回答 (3 件)

Matt J
Matt J 2014 年 10 月 27 日
編集済み: Matt J 2014 年 10 月 27 日

0 投票

See the polyfit command .

1 件のコメント

Matlabuser
Matlabuser 2014 年 10 月 27 日
I already tried with command, I want to fit polynomial manually

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

Matlabuser
Matlabuser 2014 年 10 月 28 日

0 投票

Can anyone please tell me how can I fit logarithmic polynomial to time series
Thanks in advance

カテゴリ

ヘルプ センター および File ExchangeFit Postprocessing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by