How can plot individual mode shapes of a cantilever beam with a tip mass?

26 vues (au cours des 30 derniers jours)
Jjoyner
Jjoyner le 6 Oct 2019
Commenté : Star Strider le 6 Oct 2019
I have been given code by my professor to solve for the roots of the characteristic equation of a cantilever beam.
% Material and geometric properties -- correct these!
EI = .75897; % Young's modulus * moment of inertia
rhoA = .1192506; % density * cross-sectional area
L = .613; % length
M = .0053; % tip mass
BL = 0:0.01:15; % array of beta*L values
mu = M / rhoA / L; % normalized tip mass
for iB = 1:length(BL) % loop over all values of beta*L
s=sin(BL(iB)); c=cos(BL(iB)); % just saving space in next
sh=sinh(BL(iB)); ch=cosh(BL(iB)); % by using s, c, sh, ch
c1=mu*BL(iB)*s-c; c2=s+mu*BL(iB)*c;
c3=ch+mu*BL(iB)*sh; c4=sh+mu*BL(iB)*ch;
chareq(iB) = det([ 0 1 0 1; % from zero disp at x=0
1 0 1 0; % from zero slope at x=0
-s -c sh ch; % from zero moment at x=L
c1 c2 c3 c4]); % from tip mass force at x=L
end
plot(BL,chareq); axis([0 15 -10 10]); grid on
xlabel('\betaL'); ylabel('det[A]')
I have also been instructed to plot the first three mode shapes (corresponding to the first three Beta-L values). This is my attempt:
B1=1.752;
X=0:.05:.7;
s=sin(B1*X); c=cos(B1*X);
sh=sinh(B1*X); ch=cosh(B1*X);
c1=mu*B1*s-c; c2=s+mu*B1*c;
c3=ch+mu*B1*sh; c4=sh+mu*B1*ch;
f=s+(c2*c)+(c3*sh)+(c4*ch);
plot(x,f)
I am getting this error and I am not exactly sure why:
Error using *
Inner matrix dimensions must agree.
Error in PL4Starter (line 39)
f=s+(c2*c)+(c3*sh)+(c4*ch);
This is in the same file as the previous code, so existing variables are still defined. Can anyone offer some help here?
I am not too familiar with MATLAB and understanding syntax, even with the help of documentation, is a struggle. I have coded in C and python, so I am familiar with typical programming syntax.

Réponses (1)

Star Strider
Star Strider le 6 Oct 2019
You need to use element-wise operations (.* for element-wise multiplication instead of * that is used for matrix multiplication):
f=s+(c2.*c)+(c3.*sh)+(c4.*ch);
See Array vs. Matrix Operations for details.
Also, MATLAB is case sensitive, so change your plot arguments to:
plot(X,f)

Catégories

En savoir plus sur Vibration Analysis dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by