How does this code solve the problem of incorrectly using vertcat to concatenate arrays with inconsistent dimensions?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear;
clc;
w1=1;
l1=0.125;
l3=0.600;
l4=0.150;
l6=0.275;
l61=0.575;
for m=1:3601
o1(m)=pi*(m-1)/1800;
o31(m)=atan((l6+l1*sin(o1(m)))/(l1*cos(o1(m))));
if o31(m)>=0
o3(m)=o31(m);
else o3(m)=pi+o31(m);
end
s3(m)=(l1*cos(o1(m)))/cos(o3(m));
o4(m)=pi-asin((l61-13*sin(o3(m)))/14);
se(m)=13*cos(o3(m))+14*cos(o4(m));
if o1(m)==pi/2
o3(m)=pi/2;
s3(m)=l1+16;
end
if o1(m)==3*pi/2
o3(m)=pi/2;
s3(m)=l6-l1;
end
A1=[cos(o3(m)),-s3(m)*sin(o3(m)),0,0;sin(o3(m)),s3(m)*cos(o3(m)),0,0;0,-l3*sin(o3(m)),-l4*sin(o4(m)),-1;0,l3*cos(o3(m)),l4*cos(o4(m)),0];
B1=w1*[-l1*sin(o1(m));l1*cos(o1(m));0;0];
D1=A1\B1;
E1(:,m)=D1;
ds(m)=D1(1);
w3(m)=D1(2);
w4(m)=D1(3);
ve(m)=D1(4);
A2=[cos(o3(m)),-s3(m)*sin(o3(m)),0,0;sin(o3(m)),s3(m)*cos(o3(m)),0,0;0,-l3*sin(o3(m)),-l4*sin(o4(m)),-1;0,l3*cos(o3(m)),l4*cos(o4(m)),0];
B2=-[-w3(m)*sin(o3(m)),(-ds(m)*sin(o3(m))-s3(m)*w3(m)*cos(o3(m))),0,0;w3(m)*cos(o3(m)),(ds(m)*cos(o3(m))-s3(m)*w3(m)*sin(o3(m))),0,0;0,-l3*w3(m)*cos(o3(m)),-l4*w4(m)*cos(o4(m)),0;0,-l3*w3(m)*sin(o3(m)),-l4*w4(m)*sin(o4(m)),0]*[ds(m);w3(m);w4(m);ve(m)];
C2=w1*[-l1*w1*cos(o1(m));-l1*w1*sin(o1(m));0;0];
B=B2+C2;
D2=A2\B;
E2(:,m)=D2;
dds(m)=D2(1);
a3(m)=D2(2);
a4(m)=D2(3);
ae(m)=D2(4);
end
o11=o1*180/pi;
y=[o3*180/pi;
04*180/pi];
w=[w3;w4];
a=[a3;a4];figure;
subplot(221);
h1=yyaxis(o11,y,o11, se);
axis equal;
title('位置线图');
xlabel('\it\thetal');
ylabel('\it\theta3,\theta4,Se');
subplot(222);
h2=yyaxis(o11,w,o11,ve);
title('速度线图');
xlabel('\it\theta1');
ylabel('\it\omega3,\omega4,Ve');
subplot(212);
h3=yyaxis(o11,a,o11,ae);
title('加速度线图');
xlabel('\it\theta1');
ylabel('\it\alpha3,\alpha4,\alphaE');
F=[o11;o3./pi*180;o4./pi*180;se;w3;w4;ve;a3;a4;ae]';
G=F(1:100:3601,:);
0 commentaires
Réponse acceptée
Voss
le 7 Juin 2024
On the line that throws the error you have:
y=[o3*180/pi;
04*180/pi];
where o3 is of size 1x3601 and 04 is a scalar (the scalar number 4). I suspect you meant to use o4, which is the same size as o3.
y=[o3*180/pi;
o4*180/pi];
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Subplots 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!