MATLAB: How do you separate imported data into time and amplitude

detrendhelpstudentundergraduateuniversity

%%i have imported notepad data into matlab, having difficulty seperating the data into seperate arrays. Any help?

Best Answer

If by detrend you mean that you want to remove the part of the signal that is growing linearly with time then the expression you have will not work. It will just shift your whole plot horizontally, so that it is centered on the mean value for the whole series.
Instead you can do a little linear regression to find the best straight line (y = mx + b) through the data, and then subtract that off.
To do this in MATLAB you could use:
% 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)
Here is a good link to learn more about the linear regression, https://www.mathworks.com/help/matlab/data_analysis/linear-regression.html