Info
この質問は閉じられています。 編集または回答するには再度開いてください。
hi members i have error using my matlab code "Subscripted assignment dimension mismatch" plz help me out.
1 回表示 (過去 30 日間)
古いコメントを表示
M=[1 0;0 2]; % mass matrix
C=[1.6 -0.8; -0.8 0.8]; % damping matrix
K=[5 -4;-4 4]; % stiffness matrix
A=[zeros(size(M)) eye(size(M));-inv(M)*K -inv(M)*C];
B=[zeros(size(M)); inv(M)];....................................(here iam getting error message)
TO=4; %RISE TIME OF FORCE
N=600;
T=0.1; % SAMPLING PERIOD
NO=TO/T;
phi=eye(size(A))+T*A+T^2*A^2/2+T^3*A^3/6;
gamma=inv(A)*(phi-eye(size(A)))*B;
x(:,1)=zeros(2*length(M),1);
for k=1:N,
if k<=NO +1; f(k)=1;
else;f(k)=0;end
F(:,k)=[0;1]*f(k); % Force is only applied to mass m
x(:,k+1)=phi*x(:,k)+gamma*F(:,k);
end
k=[0:N];
plot(k,x(1,:),'.')
title('system response for unit step at first disc E8.20')
ylabel('x_1(k)')
xlabel('k')
grid
0 件のコメント
回答 (2 件)
Michael Haderlein
2014 年 7 月 22 日
I cannot reproduce the error.
M=[1 0;0 2]; % mass matrix
C=[1.6 -0.8; -0.8 0.8]; % damping matrix
K=[5 -4;-4 4]; % stiffness matrix
A=[zeros(size(M)) eye(size(M));-inv(M)*K -inv(M)*C];
B=[zeros(size(M)); inv(M)]
B =
0 0
0 0
1.000000000000000 0
0 0.500000000000000
Maybe you have some variable x or F in the memory and the error appears in the line x(:,1)=... or F(:,k)=...? If so, delete the variables (see clear function).
Best regards, Michael
1 件のコメント
Wayne King
2014 年 7 月 22 日
編集済み: Wayne King
2014 年 7 月 22 日
There is no error there unless you have already set B equal to something in your workspace, clear the variables used here and then execute:
clearvars M C K A B
M=[1 0;0 2]; % mass matrix
C=[1.6 -0.8; -0.8 0.8]; % damping matrix
K=[5 -4;-4 4]; % stiffness matrix
A=[zeros(size(M)) eye(size(M));-inv(M)*K -inv(M)*C];
B=[zeros(size(M)); inv(M)];
B is a 4x2 matrix as expected.
1 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!