Why am I getting this incorrect dimensions error if the matrices are 3x3 and 3x1?

3 views (last 30 days)
I have written this piece of code to calculate some static mechanical system but when I try and multiply the 3x3 matrix "D" by the 3x1 column vector X{1} I get an error using *, where have I gone wrong?
%% Form mass, damping and stiffness matrices
M = [m1, 0, 0; 0, m2, 0; 0, 0, m3];
C = [c1, 0, 0; 0, c2, -c2; 0, -c2, c2];
K = [k1+k2+k4, -k2, -k4; -k2, k2+k3, -k3; -k4, -k3, k3+k4];
%% Calculate associated dynamics matrix
D = K\M;
%% Scaled power method
X{1} = [1; 1; 1]; % "guessed" eigenvector
N = 5; % number of iterations
for i = 1:(N-1)
X{i+1} = X{i}*D;
X{i+1} = X{i+1}./(abs(max(X{i+1}(:))));
disp(X{i+1});
end

Accepted Answer

KSSV
KSSV on 17 Nov 2018
Edited: KSSV on 17 Nov 2018
X{i}*D should be D*X{i}
M = [m1, 0, 0; 0, m2, 0; 0, 0, m3];
C = [c1, 0, 0; 0, c2, -c2; 0, -c2, c2];
K = [k1+k2+k4, -k2, -k4; -k2, k2+k3, -k3; -k4, -k3, k3+k4];
%% Calculate associated dynamics matrix
D = K\M;
%% Scaled power method
X{1} = [1; 1; 1]; % "guessed" eigenvector
N = 5; % number of iterations
for i = 1:(N-1)
X{i+1} = D*X{i};
X{i+1} = X{i+1}./(abs(max(X{i+1}(:))));
disp(X{i+1});
end

More Answers (0)

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!