Clear Filters
Clear Filters

error: elobrate on it

3 views (last 30 days)
Meyyappan
Meyyappan on 18 May 2012
% Optimization of Tuned mass damper parameters
wn = input('natural frequency of main system, wn:');
z = input('damping factor,z:');
ms = input('mass of main system, ms:');
md = input('mass of damper system, md:');
% Tuned damper parameters
kd = input('Stiffness of damper, kd:');
zd = input('damping factor, zd:');
wd = kd/md;
w = 0:1:1000;
% Non-dimensional parameters
r = w/wn;
rd = wd/wn;
m = ms/md; % Fixed for a setup
for s=1: length(r)
G(s,:)= sqrt((rd.^2-r.^2).^2+4*zd.^2*rd.^2*r.^2)./{((1-r.^2)*(rd.^2-r.^2)-m*rd.^2*r.^2-4*z*zd*rd*r.^2).^2+4*(zd*rd*r*(1-r.^2-m*r.^2)+z*r*(rd.^2-r.^2)).^2}.^(1/2);
Re(s,:) = {(rd.^2 -r.^2)*(1-r.^2)*(rd.^2-r.^2)-m*rd.^2*r.^2+ 4*(zd.^2*rd.^2*r.^2*(1-r.^2-m*r.^2))}./{((1-r.^2)*(rd.^2-r.^2)-m*rd.^2*r.^2-4*z*zd*rd*r.^2).^2+4*(zd*rd*r*(1-r.^2-m*r.^2)+z*r*(rd.^2-r.^2)).^2}.^(1/2);
end
figure (1)
plot(r,G)
xlabel ('\omega/\omega_n')
ylabel ('|x (i\omega)|/F')
grid
figure (2)
plot(r, Re)
xlabel ('\omega/\omega_n')
ylabel ('Non-dimensional real part (Re)')
grid
error:
Error using *
Inner matrix dimensions must agree.
Error in two_dof (line 16)G(s,:) = sqrt((rd.^2-r.^2).^2+4*zd.^2*rd.^2*r.^2)./{((1-r.^2)*(rd.^2-r.^2)-m*rd.^2*r.^2-4*z*zd*rd*r.^2).^2+4*(zd*rd*r*(1-r.^2-m*r.^2)+z*r*(rd.^2-r.^2)).^2}.^(1/2);

Accepted Answer

Walter Roberson
Walter Roberson on 18 May 2012
The "*" operator is matrix multiplication.
Your variable "r" is a row vector, so (1-r.^2) is a row vector and (rd.^2-r.^2) is a row vector of the same length. You cannot matrix-multiply a 1 x N array by a 1 x N array: matrix multiplication requires that the second dimension of the first array be the same as the first dimension of the second array.
If your code gets past that, then your code will still fail, as you cannot apply arithmetic operations such as division to cell arrays. The {} brackets are only for building cell arrays. The [] brackets are only for building vectors and matrices. The () brackets are the only arithmetic grouping operators in MATLAB.
  1 Comment
Meyyappan
Meyyappan on 21 May 2012
Walter thankz for ur kind info. I have ended up in correcting the mistakes.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!