Borrar filtros
Borrar filtros

Rotating X & Y Data

40 visualizaciones (últimos 30 días)
Tania
Tania el 20 de Sept. de 2022
Comentada: Star Strider el 27 de Sept. de 2022
Hello
I am trying to rotate GPS data, that has been con verted into X & Y coordintes to dsplay lengthwy along the Y axis strting at 0,0
I'm trying to rotate data in a 6135 x 15 table, where the data is layed out as follows 6135 data points of coordintes seperted into X & yXcolumns for each person.
Time I Person 1 x I Person 1 y I Person 2 x I Person 2 y I Person 3 x I Person 3 y .....etc
I would like to rotate this date to run length way along the Y axis. Each line represents data for a different person (7 in total):
Is there a way to rotate a large table of X & Y coordinates.
Thank you in advance for your help!

Respuesta aceptada

Star Strider
Star Strider el 20 de Sept. de 2022
See if the rotate function will work.
  9 comentarios
Tania
Tania el 27 de Sept. de 2022
Thanks for your help with this!
Star Strider
Star Strider el 27 de Sept. de 2022
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 20 de Sept. de 2022
p1 = rand(2,1) ;
p2 = rand(2,1) ;
%%rotation matrix
th = 90*pi/180 ;
R = [cos(th) -sin(th) ;sin(th) cos(th)] ;
%%rotate points
pr2 = R*p2 ;
figure
hold on
plot([p1(1) p2(1)],[p1(2) p2(2)] ,'r') ;
plot([p1(1) pr2(1)],[p1(2) pr2(2)] ,'b') ;
  5 comentarios
Tania
Tania el 23 de Sept. de 2022
Hello
I've attempted to rotate my data using the below code:
Note xy2 is the data set (6135x2 matrix)
theta = atan2(xy2(:,2),xy2(:,1));
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
RR = R(1:6135,:).*xy2;
As R is double the length of the xy2 data set I select the first 6135 rows in enable multiplication for the rotated (RR) dataset.
The below graph is the original xy2 dataset in a scatter:
This next graph below is of the rotated data RR
Instead of rotating it has flipped the data set. I need the data rotted so it runs longitudinally along the Y axis.
Without guessing the theta angle is there a way to correctly determine the rotation angle I need?
Thanks is advance for your help.
Tania
Tania el 23 de Sept. de 2022
As a reference (continued from comment above):
I originally converted the ray Lat/Lon co-ordinates to X & Y coordinates using the following:
[x1,y1]= wgs2utm((data1(:,2)),(data1(:,3))) % I repeated this for each person
I then plotted each converted X & Y data point onto the graph above using the following code:
PlotGPS = scatter(Newdata(:,1),Newdata(:,2)); %Plots all the GPS data in a scatter to select 4 grid coordinates%
hold on
scatter(Newdata(:,3),Newdata(:,4));
scatter(Newdata(:,5),Newdata(:,6));
scatter(Newdata(:,7),Newdata(:,8));
scatter(Newdata(:,9),Newdata(:,10));
scatter(Newdata(:,11),Newdata(:,12));
scatter(Newdata(:,13),Newdata(:,14));
hold off
From here I used:
[PlotGPS] = ginput(4)
To create a boundary around the data points representing an (almost rectangular) field (shown by small light blue circles).
I then used the below code to rotate the boundary
Boundary = PlotGPS([2 4 3 1 2],:);
Boundlong = PlotGPS(4,:) - PlotGPS(2,:); % Length of line - long line
Boundshort = PlotGPS(1,:)- PlotGPS(2,:); % Width of line - short line
%% Rotational Matrix
theta = atan2(Boundlong(2),Boundlong(1)); % theta is in radians
R = [cos(theta) -sin(theta); sin(theta) cos(theta)]; % rotation matrix
BoundR = Boundary*R; %Rotate the field
This worked, (see above).
From my last post I'm now able to rotate, the X & Y dta points, hopwever as you can see in my last post its not rotating correctly.
Is there a way to use the boundary reference information to rotate my X & Y data?
Thanks in advance for your help/insight.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by