16 views (last 30 days)
Show older comments
Trong Nhan Tran on 18 May 2024
Edited: Trong Nhan Tran on 20 May 2024
Open in MATLAB Online
% Using the MATLAB function “roots” for find non-zero natural frequencies
% define symbolic variable w
syms w;
% Given parameters
m1 = 1.8; m2 = 6.3; m3 = 5.4; m4 = 22.5; m5 = 54;
c2 = 10; c3 = 0.5; c4 = 1.50; c5 = 1.1;
k2 = 100000; k3 = 50; k4 = 75; k5 = 10;
% Set up system matrices
% mass matrix
M = diag([m1, m2, m3, m4, m5]);
% damping matrix
C = [c2 -c2 0 0 0;
-c2 c2+c3 -c3 0 0;
0 -c3 c3+c4 -c4 0;
0 0 -c4 c4+c5 -c5;
0 0 0 -c5 c5];
% stiffness matrix
K = [k2 -k2 0 0 0;
-k2 k2+k3 -k3 0 0;
0 -k3 k3+k4 -k4 0;
0 0 -k4 k4+k5 -k5;
0 0 0 -k5 k5];
% Calculate frequency equation
Zw = w^2*M + 1i*w*C + K; % impedance matrix
freqEq = det(Zw); % take determinant to get frequency equation
pretty(simplify(freqEq)); % display simplified frequency equation
% Display the non-zero natural frequencies
disp('Non-zero natural frequencies (Hz):');
disp(root(freqEq))
11 Comments Show 9 older commentsHide 9 older comments
Show 9 older commentsHide 9 older comments
John D'Errico on 18 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3164996
Edited: John D'Errico on 18 May 2024
Please stop posting the same question multiple times. If you want to expand on a question, then do so by editing the question, or by adding a comment. I closed the last question as a duplicate. In fact, since this is now at least the third time you asked this question...
Trong Nhan Tran on 18 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165006
⋮
Sry i closed the last one. I had figured out how to do it, so this is my new question to use root to find natural frequency
Torsten on 18 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165011
Open in MATLAB Online
disp(vpa(root(freqEq)))
instead of
disp(root(freqEq))
Trong Nhan Tran on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165386
Error using indexing (line 918)
Invalid MATLAB indexing or symbolic function definition. Symbolic function arguments must be symbolic variables
and function body must be convertible to sym expression.
Error in PartA_b (line 37)
disp(vpa(root(freqEq)))
Related documentation
I got this error when i used disp(root(freqEq))
Torsten on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165426
Edited: Torsten on 19 May 2024
Open in MATLAB Online
If you use the code from above, you won't get this error (at least if you work with MATLAB R2024a).
syms w
% Given parameters
m1 = 1.8; m2 = 6.3; m3 = 5.4; m4 = 22.5; m5 = 54;
c2 = 10; c3 = 0.5; c4 = 1.50; c5 = 1.1;
k2 = 100000; k3 = 50; k4 = 75; k5 = 10;
% Set up system matrices
% mass matrix
M = diag([m1, m2, m3, m4, m5]);
% damping matrix
C = [c2 -c2 0 0 0;
-c2 c2+c3 -c3 0 0;
0 -c3 c3+c4 -c4 0;
0 0 -c4 c4+c5 -c5;
0 0 0 -c5 c5];
% stiffness matrix
K = [k2 -k2 0 0 0;
-k2 k2+k3 -k3 0 0;
0 -k3 k3+k4 -k4 0;
0 0 -k4 k4+k5 -k5;
0 0 0 -k5 k5];
% Calculate frequency equation
Zw = w^2*M + 1i*w*C + K; % impedance matrix
freqEq = det(Zw); % take determinant to get frequency equation
pretty(simplify(freqEq)); % display simplified frequency equation
10 9 8 7 63720087 w w 2875076127i 13291777051299 w w 1518467207049i 353165987709 w 5 4 3 2----------- + -------------- + ----------------- + ----------------- + --------------- + w 34610882040i + 829211728500 w + w 47283750000i + 337500000000 w 50 5000 2500 500 2
% Display the non-zero natural frequencies
disp('Non-zero natural frequencies (Hz):');
Non-zero natural frequencies (Hz):
%disp(root(freqEq))
disp(vpa(root(freqEq)))
Trong Nhan Tran on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165431
Edited: Trong Nhan Tran on 20 May 2024
I dont know what is the wrong here about my code or somthing cuz looking like the answer is 100% worng, the number is too small and a lot of frquencies instead of 5 degree of freedoms. I no idea what wrong with this.
Torsten on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165461
Edited: Torsten on 19 May 2024
Open in MATLAB Online
I don't have experience with the physical background of your equations.
Just solving your system for omega gives a similar result as yours - only the 1i's are missing.
syms w
% Given parameters
m1 = 1.8; m2 = 6.3; m3 = 5.4; m4 = 22.5; m5 = 54;
c2 = 10; c3 = 0.5; c4 = 1.50; c5 = 1.1;
k2 = 100000; k3 = 50; k4 = 75; k5 = 10;
M1 = [-k2, k2, 0, 0, 0;k2, -k3-c3-k2, k3+c3, 0, 0;0, k3, -k4-c4-k3, k4+c4, 0;0, 0, k4, -k5-c5-k4, k5+c5;0, 0, 0, k5, -k5];
M2 = [-c2, c2, 0, 0, 0;c2, -c2, 0, 0, 0;0, c3, -c3, 0, 0;0, 0, c4, -c4, 0;0, 0, 0, c5, -c5];
M3 = diag([m1,m2,m3,m4,m5]);
M = M1+w*M2+w^2*M3;
ans=
vpa(root(det(M)==0))
ans=
Trong Nhan Tran on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165476
is it m1 is for matrix of stifness and m2 is damping?
Torsten on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165506
Open in MATLAB Online
I just wrote your system of equations in matrix form
M(w)*[X1;X2;X3;X4;X5] = 0
and determined the values of w for which the equation has a nontrivial solution.
Trong Nhan Tran on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165511
but i think M1 was wrong cuz it has c in stiffness matrix
K = [k2 -k2 0 0 0;
-k2 k2+k3 -k3 0 0;
0 -k3 k3+k4 -k4 0;
0 0 -k4 k4+k5 -k5;
0 0 0 -k5 k5];
Torsten on 19 May 2024
Direct link to this comment
https://webchat.mathworks.com/matlabcentral/answers/2120241-question-for-using-root-function#comment_3165616
Edited: Torsten on 19 May 2024
Open in MATLAB Online
Write your equations (1)-(5) as
M1*[X1;X2;X3;X4;X5] + w*M2*[X1;X2;X3;X4;X5] + w^2*M3*[X1;X2;X3;X4;X5] = 0
and you will see that my M1, M2 and M3 matrices are correct to reproduce your system.
But as I said: I don't know if this is how "natural frequencies" are defined.
Sign in to comment.
Sign in to answer this question.
Answers (0)
Sign in to answer this question.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office