How do you remove a trend from data without using the 'detrend' function?

6 次查看(过去 30 天)
%I have imported data into matlab and plotted the data onto a graph. I am having difficulty removing the trend without using the 'detrend' function. Any ideas on how to start this process?
A = dlmread('signal_1.txt');
x= A(:,1);
y= A(:,2);
plot(x,y);
xlabel('Time(s)');
ylabel('Amplitude');
How would i achieve this goal?

回答(2 个)

the cyclist
the cyclist 2020-2-19
Usually, when someone "doesn't want" to use a function, it means that it is homework, and they are not allowed to use a function, and are instead trying to learn something.
Here is a hint: In base MATLAB, you could use the polyfit function to find the line of best fit. That's the trend line. Then figure out how to subtract it out of your data.

Image Analyst
Image Analyst 2022-7-27
You could use the findpeaks function to find valleys in the data, then interpolate those everywhere with interp1
Here's an untested start. Adapt as needed.
[valleyValues, indexes] = findpeaks(-y);
yBaseline = interp1(x(indexes), -valueValues, x);
yCorrected = y - yBaseline;

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by