# How do you transfer this signal into linear form?

1 view (last 30 days)
James Adams on 20 Feb 2020
Commented: James Adams on 20 Feb 2020
my starting code is below. I must now convert this signal and make it linear. Any ideas on how to achieve this?
x= A(:,1); %Time Variables
y= A(:,2); %Amplitude variables
Many Thanks
Many Thanks!

Jon on 20 Feb 2020
Edited: Jon on 20 Feb 2020
The approach in the earlier post to to remove the linear trend the data was:
% make regression matrix, A where
% y = A*c + error
A = [x(:) ones(size(x(:)))]
% Find least squares solution (regression) for constants c that provide best fit for
% y = c(1)*x + c(2) using Matlab \ operator
c = A\y
% remove the linear growth (detrend) the data
yDetrended = y - (c(1)*x + c(2))
% plot the result
plot(x,yDetrended)
Looking at your new dataset signal_2.txt, it looks like the data now has a parabolic (quadratic) trend to remove.
You could modify the previous approach to instead fit a quadratic curve to the data and then subtract it off.
% make regression matrix, A where
% y = A*c + error
A = [x(:).^2 x(:) ones(size(x(:)))]
% Find least squares solution (regression) for constants c that provide best fit for
% y = c(1)*x^2 + c(2)*x + c(3) using Matlab \ operator
c = A\y
% remove the quadratic trend from the data
yDetrended = y - A*c % note A*c = (c(1)*x.^2 + c(2)*x + c(3))
figure
% plot the result
plot(x,yDetrended)
p.s. If you have a signal_3.txt that has a cubic trend, I think you can figure out what to do from here :)

#### 1 Comment

James Adams on 20 Feb 2020
Your updated version has helped me very much. Thank you so much. Have a great day :)