Matlab Code

Unformatted Attachment Preview

1
Robot Modelling (RMB600)
Name
Tutor
Course
Date
Basic
A
function T = transformationMatrix(a, b, w)
% Create the 3×3 translation matrix
translationMatrix = eye(3);
translationMatrix(1, 3) = a;
translationMatrix(2, 3) = b;
% Create the 3×3 rotation matrix
rotationMatrix = [cos(w), -sin(w), 0;
sin(w), cos(w), 0;
0,
0,
1];
2
% Combine translation and rotation matrices
T = translationMatrix * rotationMatrix;
End
Explanation
In order to acquire the transformed coordinates in the other frame, in the preceding
code, replace u and v with the coordinates that you desire to use as input.
a = 2; % Translation along the x-axis
b = 3; % Translation along the y-axis
w = pi/4; % Rotation angle (in radians)
% Get the transformation matrix
T = transformationMatrix(a, b, w);
% Transform coordinates [u;v;1] to [x;y;1]
uv = [u; v; 1];
xy = T * uv;
% Extract the transformed x and y coordinates
x = xy(1);
3
y = xy(2);
B
function plot2DFrame(xlim, ylim, xlabel_text, ylabel_text, origin)
% Create a figure
figure;
hold on;
% Set axis limits
axis([xlim ylim]);
% Plot x-axis
plot([xlim(1), xlim(2)], [0, 0], ‘k’); % x-axis
% Plot y-axis
plot([0, 0], [ylim(1), ylim(2)], ‘k’); % y-axis
4
% Plot origin
plot(origin(1), origin(2), ‘ro’); % Origin point
% Add labels
xlabel(xlabel_text);
ylabel(ylabel_text);
% Add grid
grid on;
% Set aspect ratio to be equal
axis equal;
% Hold off to stop adding to the current plot
hold off;
end
explanation
In order to personalize the plot, it is good …
Purchase document to see full attachment

Don't use plagiarized sources. Get Your Custom Assignment on
Matlab Code
From as Little as $13/Page