Rotate set of data points

조회 수: 5 (최근 30일)
Abhishek Mishra
Abhishek Mishra 2023년 1월 13일
댓글: Abhishek Mishra 2023년 1월 13일
I have a velocity curve which I need to rotate such that the right end remains at the same position where as the left end is rotated to 0 value(y-coordinate). How can I achieve this keeping the curve profile same?

채택된 답변

Mathieu NOE
Mathieu NOE 2023년 1월 13일
hello
see below
the home made solution performs better than built in detrend matlab function (even with 'linear' argument)
%% dummy data
N=1000; % Number of data points
t=[0:1:N-1]/N;
y = 1.5*(1 - t);
y2=sin(20*t)+y;
y(100:N-100) = y2(100:N-100);
%% solution 1
ynew1 = detrend(y,'linear');
%% solution 2 (home made)
dy = y(1) - y(end); % if you want start and end point at same Y value (zero or non zero)
yc = linspace(dy,0,numel(y));
ynew2 = y - yc;
plot(t,y,t,ynew1,t,ynew2)
legend('initial data','linear detrend','home made detrend');
  댓글 수: 1
Abhishek Mishra
Abhishek Mishra 2023년 1월 13일
Thank you! The second solution worked really good.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by