make utm rotated grid with rotation vector in matlab

To create a rotated grid with rotation in MATLAB, you can use the following code snippet using the meshgrid function along with rotation matrix:

main.m
% Create a grid
[x, y] = meshgrid(-100:100, -100:100);

% Define rotation angle in degrees
theta = 30; 

% Convert rotation angle to radians
theta = deg2rad(theta);

% Rotation matrix
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];

% Perform rotation
rotated_coords = R * [x(:)'; y(:)'];
x_rotated = reshape(rotated_coords(1, :), size(x));
y_rotated = reshape(rotated_coords(2, :), size(y));

% Plot the rotated grid
figure;
imshow(zeros(size(x)));
hold on;
plot(x_rotated, y_rotated, 'r');
497 chars
23 lines

This code creates a grid, rotates it by 30 degrees, and then plots the rotated grid. You can adjust the rotation angle theta to any desired value.

gistlibby LogSnag