Hi, I am a chemist and looking to do some smoothing on my data, but don't want it to be drastic, therefore I was trying to use the y=sgolayfilt(x,order,framelen) in MATLAB and input a polynomial order of over 500 for example, but each time I try to use an order above 110 the function returns 'NaN' for my whole matrix.
ANSWER
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
I suspect you are confusing the order and the window length of the filter You should try first with low order filters (1 to 3 say) and then vary window length an order above 100 seems to me way out the useful range For what it is worth , below a code with different smoothing techniques Fs = 1000;
samples = 1000;
dt = 1/Fs;
t = (0:samples-1)*dt;
y = square(2*pi*3*t) + 0.1*randn(size(t));
% %%%%%%%%%%%%%%%%
figure(1)
N = 10;
ys = slidingavg(y, N);
plot(t,y,t,ys);legend('Raw','Smoothed');
title(['Data samples at Fs = ' num2str(round(Fs)) ' Hz / Smoothed with slidingavg' ]);
% %%%%%%%%%%%%%%%%
figure(2)
N = 10;
ys = medfilt1(y, N,'truncate');
plot(t,y,t,ys);legend('Raw','Smoothed');
title(['Data samples at Fs = ' num2str(round(Fs)) ' Hz / Smoothed with medfilt1' ]);
grid on
%%%%%%%%%%%%%%%%
figure(3)
N = 10;
ys = sgolayfilt(y,3,51);
plot(t,y,t,ys);legend('Raw','Smoothed');
title(['Data samples at Fs = ' num2str(round(Fs)) ' Hz / Smoothed with sgolayfilt' ]);
grid on
%%%%%%%%%%%%%%%%
NN = 4;
Wn = 0.1;
[B,A] = butter(NN,Wn);
SEE COMPLETE ANSWER CLICK THE LINK
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Fs = 1000; samples = 1000; dt = 1/Fs; t = (0:samples-1)*dt; y = square(2*pi*3*t) + 0.1*randn(size(t)); % %%%%%%%%%%%%%%%% figure(1) N = 10; ys = slidingavg(y, N); plot(t,y,t,ys);legend('Raw','Smoothed'); title(['Data samples at Fs = ' num2str(round(Fs)) ' Hz / Smoothed with slidingavg' ]); % %%%%%%%%%%%%%%%% figure(2) N = 10; ys = medfilt1(y, N,'truncate'); plot(t,y,t,ys);legend('Raw','Smoothed'); title(['Data samples at Fs = ' num2str(round(Fs)) ' Hz / Smoothed with medfilt1' ]); grid on %%%%%%%%%%%%%%%% figure(3) N = 10; ys = sgolayfilt(y,3,51); plot(t,y,t,ys);legend('Raw','Smoothed'); title(['Data samples at Fs = ' num2str(round(Fs)) ' Hz / Smoothed with sgolayfilt' ]); grid on %%%%%%%%%%%%%%%% NN = 4; Wn = 0.1; [B,A] = butter(NN,Wn);
SEE COMPLETE ANSWER CLICK THE LINK
Comments
Post a Comment