cannot plot distance with respect to Theta2.

clear
clc
% Bar details:
L1 = 5*sqrt(8^2+3^2);
thta1 = atan(3/8);
L2 = 5*sqrt(2^2+3^2);
L4 = 5*14*sqrt(2);
L5 = 5*sqrt(22^2+2^2);
H = 5* 8;
omega = 1;
% ploting input crank
for T = 0:0.1:ceil(2*pi/omega)
thta2 = T * omega;
F =tiledlayout(2,1);
nexttile;
plot([-50 50],[0 0]);hold on
plot([0 0],[-200 200]);hold on
plot([-200 200],[H H]);hold on
plot([0 L2*cos(thta2)],[0 L2*sin(thta2)],'o-','LineWidth',2);hold on
thta_2 = thta2 + pi;
L3 = sqrt((L1*cos(thta1)-L2*cos(thta_2))^2+(L1*sin(thta1)-L2*sin(thta_2))^2);
thta3 = asin((L1*sin(thta1)-L2*sin(thta_2))/L3);
thta4 = thta3+pi;
thta5 = asin((-55-L4*sin(thta4))/L5);
L6 = -(L5*cos(thta5)+L4*cos(thta4));
%ploting coupler
plot([-40 L4*cos(thta3)-40],[-15 L4*sin(thta3)-15],'o-','LineWidth',2);hold on
% ploting output rod
plot([L4*cos(thta3)-40 L4*cos(thta3)-40-L5*cos(thta5)],[L4*sin(thta3)-15 H],'o-','LineWidth',2);hold off
axis(gca,'equal');
axis([-250 250 -250 250]);
nexttile;
plot(thta2,L6,'-');
pause(0.1);
end
what ever i do i just cannot execute the last plot action and it just shows a blank graph that doesnt change(it moves and y cordinates move around the value but overall it does not show anythign)

Respuestas (1)

Voss
Voss el 4 de Jun. de 2022
L6 and thta2 are scalars, so you're plotting one point at a time. A line with one point doesn't show up unless it has a marker, so change this:
plot(thta2,L6,'-'); % solid line, no marker
to this:
plot(thta2,L6,'.'); % no line, '.' marker
(or use some other marker besides '.', e.g., 'o', 'x', or '^', etc.)
Then you will see the point move as the code runs.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 4 de Jun. de 2022

Respondida:

el 4 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by