error: elobrate on it
조회 수: 3 (최근 30일)
이전 댓글 표시
% 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);
댓글 수: 0
채택된 답변
Walter Roberson
2012년 5월 18일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Nonlinear ARX Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!