Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to remove this ERROR: Inner matrix dimensions must agree

1 回表示 (過去 30 日間)
Ahmad Sheikh
Ahmad Sheikh 2015 年 7 月 7 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
First i have done this example
function derivative_x = book_TS(t,x)
derivative_x = zeros(2,1);
z1=x(1).*(x(2).^2);
z2=(3+x(2)).*(x(1).^2);
a1=1;
a2=-1;
b1=4;
b2=0;
M1=(a1-z1)./(a1-a2)
M2=(z1-a2)./(a1-a2)
M3=(b1-z2)./(b1-b2)
M4=(z2-b2)./(b1-b2)
h1= M1.*M3
h2= M1.*M4
h3= M2.*M3
h4= M2.*M4
A1=[-1 1;4 -1];
A2=[-1 1;0 -1];
A3=[-1 -1;4 -1];
A4=[-1 -1;0 -1];
derivative_x = h1*A1*x + h2*A2*x + h3*A3*x + h4*A4*x;
and run this function in another file
Initial_Time=0;
Final_Time=10;
[x1,x2] = meshgrid(-2:0.1:2);
[t,x] = ode45(@book_TS, [Initial_Time Final_Time], [0.5 0.5]);
figure(1);
plot(t,x(:,1));
%axis([0 10 144 152]);
xlabel('time')
ylabel('state x1k')
plot(t,x(:,2));
xlabel('time')
ylabel('state x2k')
axis([0 5 -5 5]);
its not giving any error
but when i run this code
derivative_x = example_aircraft(t,x);
derivative_x = zeros(4,1);
VT = linspace(100,200);
alpha = linspace(-20,20);
q = linspace(-45,45);
g=9.8;
z1= -g.*sin(x(2)).*sin(x(4))-g.*cos(x(2)).*cos(x(4));
z2= -z1-1.1794.*sin(x(2))+116.5903;
z3= 0.0654.*cos(x(2)).*sin(x(4))-0.0654.*sin(x(2)).*sin(x(4))-0.0079.*cos(x(2))-1.7723;
z4= 0.065.*sin(x(2)).*cos(x(4))-0.065.*cos(x(2)).*sin(x(4));
a1 = max(z1)
a2 = min(z1)
b1 = max(z2)
b2 = min(z2)
c1 = max(z3)
c2 = min(z3)
d1 = max(z4)
d2 = min(z4)
a= a1-a2;
b= b1-b2;
c= c1-c2;
d= d1-d2;
M11= (a1-z1)./a;
M12= (z1-a2)./a;
M21=(b1-z2)./b;
M22=(z2-b2)./b;
M31=(c1-z3)./c;
M32=(z3-c2)./c;
M41= (d1-z4)./d;
M42= (z4-d2)./d;
h1= M11.*M21.*M31.*M41;
h2= M11.*M21.*M31.*M42;
h3= M11.*M21.*M32.*M41;
h4= M11.*M21.*M32.*M42;
h5= M11.*M22.*M31.*M41;
h6= M11.*M22.*M31.*M42;
h7= M11.*M22.*M32.*M41;
h8= M11.*M22.*M32.*M42;
h9= M12.*M21.*M31.*M41;
h10= M12.*M21.*M31.*M42;
h11= M12.*M21.*M32.*M41;
h12= M12.*M21.*M32.*M42;
h13= M12.*M22.*M31.*M41;
h14= M12.*M22.*M31.*M42;
h15= M12.*M22.*M32.*M41;
h16= M12.*M22.*M32.*M42;
A1 =[24.6375 126.0927 -2.0799 -11.0439;2.8964 -0.1925 0.7555 -0.2115;372.8234 206.8231 -32.1499 -18.8528;0 0 1.0000 0];
A2 =[42.0463 54.6393 -3.5089 -4.9256;4.9429 -8.5926 0.5875 0.6378;636.2595 -874.4336 -53.7727 73.7308;0 0 1.0000 0];
A3 =[25.3637 127.7778 -2.1400 -11.1881;2.9817 0.1899 0.7484 -0.2284;383.8125 232.3232 -33.0593 -21.0361;0 0 1.0000 0];
A4 =[2.5094 91.4323 -0.2504 -8.1316;0.2950 -4.0828 0.9706 0.2609;37.9736 -317.6703 -4.4639 25.2158;0 0 1.0000 0];
A5 =[55.1348 62.0700 -4.0440 -4.9149;6.4816 -9.5219 0.5246 0.5091;834.3190 -994.0568 -61.8713 73.8932;0 0 1.0000 0];
A6 =[3.4519 102.5201 -0.2999 -7.9175;0.4058 -4.7666 0.9647 0.2861;52.2359 -381.9531 -5.2136 28.4566;0 0 1.0000 0];
A7 = 1.0e+003 *[0.0553 0.0591 -0.0041 -0.0047;0.0065 -0.0097 0.0005 0.0005;0.8365 -1.0397 -0.0621 0.0775;0 0 0.0010 0];
A8 =[-5.5933 128.1978 0.2276 -9.7718;-0.6575 -1.5636 1.0268 0.0681;-84.6401 6.6110 2.7688 0.3964;0 0 1.0000 0];
A9 =[ -0.2058 105.6963 -0.0284 3.8585; -0.0242 -2.5903 0.9967 -0.0908; -3.1150 -101.8214 -1.1059 -3.3254; 0 0 1.0000 0];
A10 =[-0.5648 107.4579 0.0009 3.9265; -0.0664 -2.3832 1.0001 0.0472; -8.5462 -75.1656 -0.6616 -2.2961; 0 0 1.0000 0];
A11 =[ -0.1893 106.0870 -0.0299 3.8727; -0.0223 -2.3600 0.9965 -0.0892; -2.8646 -95.9095 -1.1273 -3.1102; 0 0 1.0000 0];
A12 =[ -1.0557 111.8179 0.0254 4.1036; -0.1241 -1.6863 1.0030 0.0680; -15.9758 -9.1883 -0.2904 0.3842; 0 0 1.0000 0];
A13 =[ -0.2635 121.1984 -0.0265 3.8911; -0.0310 -2.5708 0.9969 -0.0870; -3.9880 -99.3064 -1.0764 -2.8321; 0 0 1.0000 0];
A14 =[-0.6996 123.5013 0.0039 3.9708; -0.0822 -2.3000 1.0005 0.0524; -10.5860 -64.4576 -0.6163 -1.6263; 0 0 1.0000 0];
A15 =[ -0.2338 121.5219 -0.0287 3.9013; -0.0275 -2.3484 0.9966 -0.0858; -3.5376 -94.4112 -1.1094 -2.6768; 0 0 1.0000 0];
A16 =[-0.6592 123.1979 0.0018 3.9604; -0.0775 -2.1514 1.0002 0.0511; -9.9759 -69.0492 -0.6487 -1.7832; 0 0 1.0000 0];
==>> derivative_x = h1*A1*x + h2*A2*x + h3*A3*x + h4*A4*x + h5*A5*x + h6*A6*x + h7*A7*x + h8*A8*x + h9*A9*x + h10*A10*x + h11*A11*x + h12*A12*x +h13*A13*x + h14*A14*x + h15*A15*x + h15*A16*x;
Initial_Time=0;
Final_Time=10;
[x1,x2] = meshgrid(-2:0.1:2);
[t,x] = ode45(@example_aircraft, [Initial_Time Final_Time], [0 10 11 0 0 0]);
figure(1);
plot(t,x(:,1));
%axis([0 10 144 152]);
xlabel('time')
ylabel('state x1k')
plot(t,x(:,2));
xlabel('time')
ylabel('state x2k')
axis([0 5 -5 5]);
it's giving an error where i put arrow ''Inner matrix dimensions must agree'' i dont understand how to remove this...?

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by