Help with Matlab plotting

Is anybody able to help me with plotting in Matlab? I need to be able to plot a free body diagram with scaled vectors showing the different forces. I'm able to solve the equation in Matlab but am having trouble finding a way to plot it like shown in the picture. Any help would be greatly appreciated. I just need to figure out how to plot the bar at least.

Answers (1)

Here is a basic template
To plot the bar, you can use polyshape:
x = [ 0 , 0 , 18, 18];
y = [-0.5, 0.5, 0.5,-0.5];
beam=polyshape(x,y)
h=plot(beam); hold on;
h.FaceColor=[0,0,0]; h.EdgeColor=[0,0,0]; % Set color to black
axis equal, grid on
To plot an arrow, you can use annotation, like so:
greenarrow = annotation('arrow', 'LineWidth', 5, 'Color', 'g', 'HeadLength', 16, 'HeadWidth', 32);
greenarrow.Parent=gca;
greenarrow.Position=[8,0,0,-2]; % X1 Y1 deltaX deltaY, tip of the arrow is at (x1+deltaX,Y1+deltaY)
(dont forget to use the correct lengths for your freebody diagram)
Finally, you can add a marker for the roller or the hinge like so:
plot(0,-0.5,'.','MarkerSize',46);
axis equal, grid on, box on
This should be enough to help you get started

Asked:

on 12 Apr 2018

Answered:

about 3 hours ago

Community Treasure Hunt

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

Start Hunting!