MATLAB: How to make this signal linear

data importimportlinearnonlinearstudenttrendundergraduateuniversity

Here is my code so far on how to produce this plot. Any ideas on how to make this plot linear?
A = dlmread('signal_2.txt'); %Reads signal data file
x= A(:,1); %Time Variables
y= A(:,2); %Amplitude variables
Many Thanks

Best Answer

If you want to eliminate the low-frequency parabolic(?) trend, the easiest way is to use a digital filter:
signal_2 = load('signal_2.txt');
t = signal_2(:,1);
signal = signal_2(:,2);
figure
plot(signal_2(:,1), signal_2(:,2))
grid
xlabel('Time')
ylabel('signal')
L = numel(t);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
FTsignal = fft(signal)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTsignal(Iv))*2)
grid
title('Fourier Transform: ‘signal’')
xlabel('Frequency')
ylabel('Amplitude')
Wp = [25 75]/Fn; % Normailsed Passband (Passband = 25 Hz To 75 Hz)
Ws = [20 80]/Fn; % Normailsed Stopband (Passband = 20 Hz To 80 Hz)
Rp = 1; % Passband Ripple/Attenuation
Rs = 50; % Stopband Ripple/Attenuation
[n,Wp] = ellipord(Wp, Ws, Rp, Rs); % Calculate Elliptic Filter Optimum Order
[z,p,k] = ellip(n, Rp, Rs, Wp,'bandpass'); % Elliptic Filter
[sos,g] = zp2sos(z,p,k); % Second-Order-Section For Stability
Filtered_signal = filtfilt(sos,g,signal); % Filter
figure
plot(t, Filtered_signal)
grid
xlabel('Time')
ylabel('Filtered\_signal')
producing:
This filter also eliminates some of the high-frequency noise as well.