MATLAB: How to rotate a plot of N number of 2D points

dataMATLABplotpointsrotate

How can I rotate a plot of N number of 2D points?

Best Answer

There are two ways to accomplish the rotation, as mentioned below:
1. If you only want to rotate the plot by say "theta" degrees, then you can use the "camroll" function after you have plotted the data as follows:
camroll(theta);
The documentation is linked below if you would like more details about this function:
2. The second approach is to rotate the data using the concept of rotation matrices before plotting the data. Refer to the following Wiki link for details about rotation matrices:
You can define your rotation matrix based on the first equation on the above wiki page as:
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
Note that "theta" in this case is in radians and not degrees. Then you can rotate your data as follows:
dataRot = R * data; % data is of the size (2 x N) in this case
Once you have the rotated data, you plot the data with the "plot" command as usual.