MATLAB Answers

How do you transfer this signal into linear form?

2 ビュー (過去 30 日間)
James Adams
James Adams 2020 年 2 月 20 日
コメント済み: James Adams 2020 年 2 月 20 日
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 件のコメント

サインイン to comment.

採用された回答

Jon
Jon 2020 年 2 月 20 日
編集済み: Jon 2020 年 2 月 20 日
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 件のコメント

James Adams
James Adams 2020 年 2 月 20 日
Your updated version has helped me very much. Thank you so much. Have a great day :)

サインイン to comment.

その他の回答 (1 件)

James Adams
James Adams 2020 年 2 月 20 日
similar to the first task, I must remove the trend from the data file. I'm not sure if there is a trend to remove from signal_2.txt nor do i have any indication of how the graph should look like. I thought to my understanding I must make signal_2.txt be in the same layout as signal_1.txt. Maybe for this task there isn't a trend
what are your thoughts?
I appreciate your time and continued support

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by