Inner matrix dimensions must agree
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Valéry Ebogo
am 14 Feb. 2020
Kommentiert: Valéry Ebogo
am 14 Feb. 2020
Hi,
when I execute the following code, I get the error message "Inner matrix dimensions must agree".
The error is in line 31, which performs the multiplication of three real matrix of the same size.
this is what I can't understand.
i would like you to help me understand what is the problem.
thank you!
de=ones(5,1); u=ones(22); %dde=zeros(5,1);
Cz=0.001; %vertical deflection rate of the tyre
Cs=50000;
epsilon=0.015;
I=2.1;
Iz=1627;
R=0.35;
Ca=30000;
m=1298.9;
lf=1;
lr=1.454;
br=1.436;
bf=br;
mu=0.9;
g=9.81;
cons=m/(lr+lf);
h=0.5;
C=[0 m*u(22) 0 0 0;-m*u(22) 0 0 0 0;0 0 0 0 0;0 0 0 cos(u(21)) -sin(u(21));0 0 0 sin(u(21)) cos(u(21))];
M=[m 0 0 0 0;0 m 0 0 0;0 0 Iz 0 0;0 0 0 1 0;0 0 0 0 1];
u1=(de(2)+lf*de(3))/(de(1)+0.5*bf*de(3));
u2=(de(2)+lf*de(3))/(de(1)-0.5*bf*de(3));
u3=(de(2)-lr*de(3))/(de(1)+0.5*br*de(3)); %% les ui représentent les rapports permettant de calculer les angles de dérives de chaque roue%%
u4=(de(2)-lr*de(3))/(de(1)-0.5*br*de(3));
U=[u1 u2 u3 u4];
%------vertical load----------
dde=(-de*C)\M; % here: Inner matrix dimensions must agree !
Fz1= cons*(0.5*g*lr-0.5*dde(1)*h-lr*h*dde(2)/bf);
Fz2= cons*(0.5*g*lr-0.5*dde(1)*h+lr*h*dde(2)/bf);
Fz3= cons*(0.5*g*lr+0.5*dde(1)*h-lr*h*dde(2)/bf);
Fz4= cons*(0.5*g*lr+0.5*dde(1)*h+lr*h*dde(2)/bf);
Fz=[Fz1 Fz2 Fz3 Fz4]';
%%% velocity component in the wheel plane : is the longitunal velocity
v1=(de(1)+0.5*bf*de(3))*cos(u(1))+(de(2)+lf*de(3))*sin(u(1));
v2=(de(1)-0.5*bf*de(3))*cos(u(2))+(de(2)+lf*de(3))*sin(u(2));
v3=(de(1)+0.5*br*de(3))*cos(u(3))+(de(2)-lr*de(3))*sin(u(3));
v4=(de(1)-0.5*br*de(3))*cos(u(4))+(de(2)-lr*de(3))*sin(u(4));
V=[v1 v2 v3 v4]';
lamda=zeros(4,1);f=length(lamda);
omega=zeros(4,1);
alph=zeros(4,1);
Re=zeros(4,1);
S=zeros(4,1);
dz=zeros(4,1);
Fs=zeros(4,1);
Ft=zeros(4,1);
for i=1:4
dz(i)=-Cz*Fz(i)+ 0.33*R;
Re(i)=R-dz(i)./3;
omega(i)=(-R*u(i+16)+u(i+4))/I;
S(i)=1+omega(i)*Re(i)./V(i);
alph(i)=atan(U(i))-u(i);
lamda(i)= mu*Fz(i).*(1-S(i))*(1-epsilon*V(i).*sqrt((S(i))^2 + (tan(alph(i)))^2))./(2*sqrt((Cs^2)*(S(i))^2 + (Ca^2)*(tan(alph(i))^2)));
if lamda(i)<1
f(i)=lamda(i)*(2-lamda(i));
Fs(i)=Ca*f(i).*tan(alph(i))./(1-S(i));
Ft(i)=Cs*f(i).*S(i)./(1-S(i));
elseif lamda(i)>1
f(i)=1;
Fs(i)=Ca*f(i).*tan(alph(i))./(1-S(i));
Ft(i)=Cs*f(i).*S(i)./(1-S(i));
end
end
4 Kommentare
Murugan C
am 14 Feb. 2020
now also you will get error.
dde=(-de'*C)\M; % here: Inner matrix dimensions must agree !
K>> dde=(-de'*C)\M;
Error using \
Matrix dimensions must agree.
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!