Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

hi members i have error using my matlab code "Subscripted assignment dimension mismatch" plz help me out.

1 visualización (últimos 30 días)
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

Respuestas (2)

Michael Haderlein
Michael Haderlein el 22 de Jul. de 2014
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

Wayne King
Wayne King el 22 de Jul. de 2014
Editada: Wayne King el 22 de Jul. de 2014
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.

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by