How can I remove linear trend of a regression ?
2 views (last 30 days)
Show older comments
Hi
To remove linear trend of the curve 'figure (5)', I have used the function detrend but an error was mentioned.
The trend of the curve wanted is attached.
Please help me.
The data used are attached.
The program is
%%
%objet : traitement signal MPF
clc;
clear;
close all;
cd Z:\Matlam\Curves_oscillo_Pc %%
%% load 'data1.txt';
tmp = data1(:,1);
disp = data1(:,2);
acc = data1(:,3);
%on recupère les données Oscilloscope en Volt load 'data4V.txt';
tmpV = data4V(:,1);
Volt = data4V(:,2);
figure(3)
plot(tmpV,Volt,'b',tmpV,Volt,'r.');
xlabel('time (sec)');
ylabel('Voltage(V)');
%%
L=length(tmp)
Lv=length(tmpV)
Fs = 833333333.333; % Sampling frequency
NFFT = 2^nextpow2(L) % Next power of 2 from length of y
NFFTV = 2^nextpow2(Lv) % Next power of 2 from length of y
figure(5)
VOLT = fft(Volt,NFFT)/L; % Calcul de la FFT
amplitude = 2*abs(VOLT(1:NFFT));
f = Fs/4*linspace(0,1,NFFT/2);
semilogy(f(1:NFFT/12),2*abs(VOLT(1:NFFT/12))/(2*abs(ACC(1:NFFT/12))));
y = detrend (abs(VOLT(1:NFFT/12)))
semilogy(f(1:NFFT/12),2*(y))
xlabel('frequency [Hz]')
ylabel('FRF Volatage [V]')
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!