ODE45 to solve multiple degree of system free vibration
조회 수: 7 (최근 30일)
이전 댓글 표시
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
Rik
2023년 5월 10일
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.
채택된 답변
Torsten
2023년 5월 4일
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
Torsten
2023년 5월 6일
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 ?
추가 답변 (1개)
Sam Chak
2023년 5월 6일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!