How do you transfer this signal into linear form?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
James Adams
el 20 de Feb. de 2020
Comentada: James Adams
el 20 de Feb. de 2020
my starting code is below. I must now convert this signal and make it linear. Any ideas on how to achieve this?
A = dlmread('signal_2.txt'); %Reads signal data file
x= A(:,1); %Time Variables
y= A(:,2); %Amplitude variables
Many Thanks
Many Thanks!
0 comentarios
Respuesta aceptada
Jon
el 20 de Feb. de 2020
Editada: Jon
el 20 de Feb. de 2020
I see this is a follow up to your previous question which was answered in https://www.mathworks.com/matlabcentral/answers/506414-how-do-you-separate-imported-data-into-time-and-amplitude
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 :)
Más respuestas (1)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!