Clear Filters
Clear Filters

Connect Simulation Point to a Sperate Speed Point

1 view (last 30 days)
Hello,
I have a Simulation of the "Crank-Slider" animation of the piston motion. The simulation code is written below. I also have an equation defined for the piston velocity. I would like to connect the simulation with the equation for the piston velocity so that as the piston is moving up and down, you can see at which point the simulation is in, while looking in the figure representing the piston velocity.
l = 0.16;
L = 0.16;
r = 0.052;
lambda = L/r;
X = [0 0 0];
Y = [0 r r+l];
X_Piston = [-0.048 0.048 0.048 -0.048 -0.048]; % Piston Width
Y_Piston = [l-0.01 l-0.01 l+0.01 l+0.01 l-0.01]; % Unknown
h = plot(X,Y,'LineWidth',4,'XDataSource','X','YDataSource','Y');
axis([-2*r 2*r -1.5*r 2*r+l]); % Axis Limits
set(gca,'DataAspectRatio',[1 1 1])
grid on
grid minor
hold('all')
g = plot(X_Piston,Y_Piston,'r','LineWidth',4,'XDataSource','X_Piston','YDataSource','Y_Piston');
cylx = [-0.051 0.051 0.051 -0.051 -0.051]
cyly = [0.05 0.05 0.25 0.25 0.05]
z = plot(cylx,cyly,'k','LineWidth',4,'XDataSource','cylx','YDataSource','cyly')
CA25 = (0:0.25:720)'; % CA : -360 to 360 in 0.25 CA Deg Samples
angle = deg2rad(CA25); % CA25 Converted to Radians [rad]
% angle = (0:0.25:720)'; % angle=0:0.01:2*pi;
x_circle=r.*cos(angle);
y_circle=r.*sin(angle);
i = plot(x_circle,y_circle,'LineWidth',4)
for A = 0:4*pi/100:4*pi
x = r*cos(A) + sqrt(L^2 - r^2*sin(A).^2);
v = -(sin(A)).*w*r - (((sin(A)).*(cos(A)).*r^2)./(sqrt(L^2-r^2*sin(A).^2))).*w;
N = [r*sin(A) r*cos(A)];
P = [0 x];
X = [0 r*sin(A) 0];
Y = [0 r*cos(A) x];
Y_Piston= [x-0.02 x-0.02 x+0.02 x+0.02 x-0.02];
refreshdata(h,'caller')
refreshdata(g,'caller')
refreshdata(i,'caller')
drawnow
pause(.1)
end

Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!