## Inner matrix dimensions must agree

### Ben Newton (view profile)

on 28 Oct 2019
Latest activity Commented on by Rena Berman

### Rena Berman (view profile)

on 12 Dec 2019 at 13:57
%ben newton swansea university 956205
k = 997.584; %stiffness, units = N/m
m = 10.692; %mass, units = kg
xo = 0.026844; %initial displacement, units = m
vo = 0:0.001:5; %initial velocity, units = m/s
t = 0.735; %time, units = s
x = 0.0852; %dispacement, units = m
c = 36.84; %damping coefficient, units = kg/s
wn = sqrt(k/m); %natural frequency, units = rad/s
ccrit = 2*sqrt(k*m); %critical damping coefficient, units = kg/s
zeta = c/ccrit; %damping ratio, no units
wd = wn*sqrt(1 - zeta^2); %damped natural frequency, units = rad/s
A = sqrt((vo+zeta*wn*xo).^2 + (xo*wd)^2/wd^2);
phi = atan((xo*wd)./vo+zeta*wn*xo); %phase angle, units = radians
x@time = A.*exp(-zeta.*wn.*t)*sin((wd.*t)+phi);
%everythings fine up until the last line, gives the error using * inner matrix dimensions must agree
all matrices used are the same shape an size etc and .* has been used
but i still get the error message

Guillaume

### Guillaume (view profile)

on 7 Nov 2019
This question should not be deleted. This is a public forum not your personal support service. The price you pay for getting help is that your question can be used by others with the same problem.
Your question has been flagged so that Mathworks can restore it. They usually do.
Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 8 Nov 2019
Original question:
%ben newton swansea university 956205
k = 997.584; %stiffness, units = N/m
m = 10.692; %mass, units = kg
xo = 0.026844; %initial displacement, units = m
vo = 0:0.001:5; %initial velocity, units = m/s
t = 0.735; %time, units = s
x = 0.0852; %dispacement, units = m
c = 36.84; %damping coefficient, units = kg/s
wn = sqrt(k/m); %natural frequency, units = rad/s
ccrit = 2*sqrt(k*m); %critical damping coefficient, units = kg/s
zeta = c/ccrit; %damping ratio, no units
wd = wn*sqrt(1 - zeta^2); %damped natural frequency, units = rad/s
A = sqrt((vo+zeta*wn*xo).^2 + (xo*wd)^2/wd^2);
phi = atan((xo*wd)./vo+zeta*wn*xo); %phase angle, units = radians
x@time = A.*exp(-zeta.*wn.*t)*sin((wd.*t)+phi);
%everythings fine up until the last line, gives the error using * inner matrix dimensions must agree
all matrices used are the same shape an size etc and .* has been used
but i still get the error message
Rena Berman

### Rena Berman (view profile)

on 12 Dec 2019 at 13:57