error: too many output arguments
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi! I'm new to MATLAB, so I'd appreciate it if someone could help me. Here is my code for the position analysis of a slider-crank mechanism. Whenever I try to run the code, the command window says: "Error using UnitVector: Too many output arguments. Error in SliderCrank2 (line 29): [e1,n1] = UnitVector(0);"
% SliderCrank_Position_Analysis.m
% performs a position analysis on the slider-crank linkage and
% plots the piston position as a function of crank angle
% by Karolina Kolodziej, February 20, 2019
clear, clc;
a = 0.10; % crank length (m)
b = 0.26; % connecting rod length (m)
c = 0.0; % vertical slider offset
% Ground pins
x0 = [0;0]; % ground pin at A (origin)
% solving for conn. rod angle (theta 3) and piston pos. (d)
N = 361; % # of times to perform calc.
[xB,xC] = deal(zeros(2,N)); % allocate space for pins B and C
[theta2, theta3, d] = deal(zeros(1,N)); %".." for link angles
% Main loop
for i = 1:N
theta2(i) = (i-1)*(2*pi)/(N-1);
theta3(i) = asin((c-a*sin(theta2(i)))/b);
d(i) = a*cos(theta2(i)) + b*cos(theta3(i));
% calculate unit vectors
[e1,n1] = UnitVector(0);
[e2,n2] = UnitVector(theta2(i));
[e3,n3] = UnitVector(theta3(i));
% solve for position of point B
xB(:,i) = FindPos(x0,a,e2);
xC(:,i) = FindPos(xB(:,i),b,e3);
end
plot(theta2*180/pi,d*100,'o','Color',[153/255 153/255 153/255])
hold on
plot(theta2*180/pi,xC(1,:)*100,'Color',[0 110/255 199/255])
title('Piston Position versus Crank Angle for Slider-Crank')
xlabel('Crank angle (degrees)')
ylabel('Position (cm)')
legend('d','xC')
grid on
2 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Statics and Dynamics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!