Clear Filters
Clear Filters

Rotate set of data points

4 views (last 30 days)
Abhishek Mishra
Abhishek Mishra on 13 Jan 2023
Commented: Abhishek Mishra on 13 Jan 2023
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?

Accepted Answer

Mathieu NOE
Mathieu NOE on 13 Jan 2023
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
y = 1.5*(1 - t);
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;
legend('initial data','linear detrend','home made detrend');
  1 Comment
Abhishek Mishra
Abhishek Mishra on 13 Jan 2023
Thank you! The second solution worked really good.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!