ODE45 to solve multiple degree of system free vibration

2 views (last 30 days)
Hello,
I am trying to slove free vibration for four degree system using ode45 and function. However I am not sure why but the response of the system is a streight line. My system has four masses and four spring coefficients, with initial condtions for dispalcemnt for m1= 0.01, for m2= 0.01, for m3= 0.02, for m4= 0.01 and inital velocity 0 0 0 0 for each mass.
I am pasisng my code her. I would apprciate the feedback!
Function
function xdot = f_4degree(t,x)
global M K
A=[zeros(4,4) eye(4,4);-M\K zeros(4,4)]*x;
xdot = A.*x;
ODE45
global M K
m1=10; m2=10; m3=10; m4=10;
k1=50; k2=50; k3=50; k4=50;
M=[m1 0 0 0;0 m2 0 0;0 0 m3 0;0 0 0 m4];
K=[k1+k2 -k2 0 0;-k2 k2+k3 -k3 0;0 -k3 k3+k4 -k4;0 0 -k4 k4];
%ODE45
tspan=[0 20];
IC=[0.01 0.01 0.02 0.01 0 0 0 0];
[t,x]= ode45('f_4degree',tspan,IC);
figure(1)
plot(t,x(:,1));
legend('Repsonse')
ylabel('x(t)')
xlabel('time')
  1 Comment
Rik
Rik on 10 May 2023
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.

Sign in to comment.

Accepted Answer

Torsten
Torsten on 4 May 2023
Maybe you mean
m1=10; m2=10; m3=10; m4=10;
k1=50; k2=50; k3=50; k4=50;
M=[m1 0 0 0;0 m2 0 0;0 0 m3 0;0 0 0 m4];
K=[k1+k2 -k2 0 0;-k2 k2+k3 -k3 0;0 -k3 k3+k4 -k4;0 0 -k4 k4];
result = -M\K;
%ODE45
tspan=[0 20];
IC=[0.01 0.01 0.02 0.01 0 0 0 0];
[t,x]= ode45(@(t,x)f_4degree(t,x,result),tspan,IC);
figure(1)
plot(t,x(:,1));
legend('Repsonse')
ylabel('x(t)')
xlabel('time')
function xdot = f_4degree(t,x,result)
A=[zeros(4,4), eye(4,4);result, zeros(4,4)];
xdot = A*x;
end
  3 Comments
Karolina Kugiel
Karolina Kugiel on 6 May 2023
Is there any way how I could find response of each mass? Instead of total response?
Torsten
Torsten on 6 May 2023
I don't have experience with the physical background of your problem. Can you describe mathematically what the output for the "response of each mass" would be ?

Sign in to comment.

More Answers (1)

Sam Chak
Sam Chak on 6 May 2023
ode45 solves the problem by integrating where . So I guess you looking for states .
m1=10; m2=10; m3=10; m4=10;
k1=50; k2=50; k3=50; k4=50;
M = [m1 0 0 0;
0 m2 0 0;
0 0 m3 0;
0 0 0 m4];
K = [k1+k2 -k2 0 0;-k2 k2+k3 -k3 0;0 -k3 k3+k4 -k4;0 0 -k4 k4];
result = -M\K;
%ODE45
tspan=[0 20];
IC=[0.01 0.01 0.02 0.01 0 0 0 0];
[t,x]= ode45(@(t,x)f_4degree(t,x,result),tspan,IC);
figure(1)
subplot(221)
plot(t, x(:,1)), title('Response of m_{1}'), xlabel('t')
subplot(222)
plot(t, x(:,2)), title('Response of m_{2}'), xlabel('t')
subplot(223)
plot(t, x(:,3)), title('Response of m_{3}'), xlabel('t')
subplot(224)
plot(t, x(:,4)), title('Response of m_{4}'), xlabel('t')
% legend('Repsonse')
% ylabel('x(t)')
% xlabel('time')
function xdot = f_4degree(t,x,result)
A=[zeros(4,4), eye(4,4); result, zeros(4,4)];
xdot = A*x;
end

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!