Variable size is incorrect

1 view (last 30 days)
JAKE WISNIEWSKI
JAKE WISNIEWSKI on 14 Oct 2021
%% Calculations for a 4 bar linkage
% Orgin
Ox=0;
Oy=0;
%% Link Lengths
L1=6;
L2=2;
L3=7;
L4=9;
x_size=1
theta2=30;
%% K values
for i = 1:x_size
K1= L1(i)/L2(i);
K2= L1(i)/L4(i);
K3= (L2(i)^2-L3(i)^2+L4(i)^2+L1(i)^2)/(2*L2(i)*L4(i));
K4= L1(i)/L3(i);
K5= (L4(i)^2-L3(i)^2-L2(i)^2-L1(i)^2)/(2*L2(i)*L3(i));
end
%% Calculate OTHER variables here.
a= cosd(theta2)-K1-K2*cosd(theta2)+K3;
b= -2*sind(theta2);
c= K1-(K2+1)*cosd(theta2)+K3;
d= cosd(theta2)-K1+K4*cosd(theta2)+K5;
e= -2*sind(theta2);
f= K1+(K4-1)*cosd(theta2)+K5;
%% Calculate your thetas
for i=1:1:361
theta4(i)= 2*atand((-b-(b^2-4*a*c)^(1/2))/(2*a));
theta3(i)= 2*atand((-e-(e^2-4*d*f)^(1/2))/(2*d));
end
%% Determine the ABSOLUT position of the ENDS of each link (for plotting)
L2X =L2*cos(theta2)
L2Y =L2*sin(theta2)
L3X =L3*cos(theta2)
L3Y =L3*sin(theta2)
L4X =L4*cos(theta2)
L4Y =L4*sin(theta2)
RPX =L2X+L3X
RPY =L2Y+L3Y
%% Plot variables
line_width = 4.5;
marker_size = 9;
%% WHAT INDEX VALUE SHOULD THIS BE IF YOU WANT TO PLOT theta2 = 45 degrees?
ii = 1 % CHANGE THIS NUMBER BUT USE IT TO CREATE THE CORRECT PLOT POSITION AS REQUIRED
figure(1)
hold on
plot([0 L2X],[0 L2Y],'-^k') % Plot the ground link as black with triangles at each end. Change the line width and markersize so the the link is visible
plot([0 L3X],[0 L3Y],'-or') % Plot the crank link as red with circles at each end. Change the line width and markersize so the the link is visible
plot([0 L4X],[0 L4Y],'-og') % Plot the coupler link as green with circles at each end. Change the line width and markersize so the the link is visible
plot([0 RPX],[0 RPY],'-ob') % Plot the output link as blue with circles at each end. Change the line width and markersize so the the link is visible
I keep getting this error and Im not sure how to fix it

Answers (0)

Community Treasure Hunt

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

Start Hunting!