- Is this code contained in a single file or multiple files? What are the file names?
- What is the exact error message that appears when you run the code?
How to solve motion equation system using ODE45 solver (six motion equation system, six variables)
5 次查看(过去 30 天)
显示 更早的评论
Hello, I'm trying to solve my task for get more experience in Matlab. I watched some tutorials on internet and find some examples how to solve the equation system. The example source: http://www.mit.edu/people/abbe/matlab/ode.html
I tried to create equation (function) in matlab *.m file, and when i tried to solve it using ODE45 solver, i got a lot of errors. I'm new on Matlab, so i need some tips and advice about my task:
My *.m File:
function dyt = mokomasis2(t, y)
%---START of Variables:---------------------------------------------------
afi_1 = y(1);
w1 = y(2);
afi_2 = y(3);
w2 = y(4);
q = y(5);
diff(q,t) = y(6);
%---END of Variables:---------------------------------------------------
%---START of Values:------------------------------------------------------
%Line potential energy:
%Ep = ((1/2)*k*(r1*afi_1-r2*afi_2)^2) +((1/2)*k*(r2*afi_2-q)^2);
%System Values:
k=(5.72*(200*10^9))/1; %line density
r1=1.3; %radius 1
r2=0.65; %radius 2
m=500; %body mass
g=9.81; %free fall acceleration
Mv=100; %motor torque N
Mpas1 = k*r1*( r1*afi_1-r2*afi_2); % Mpas1 = -diff(Ep,afi_1);
I1=(Mv-Mpas1)/diff(w1,t); % Moment of inertia of first Drum
%I2*dw2dt=-DEpDafi_2
DEpDafi_2=k*r2*( r1*afi_1-r2*afi_2)+ r2*k(r2*afi_2-q); % DEpDafi_2=diff(Ep,afi_2);
I2=-DEpDafi_2/diff(w2,t); % Moment of inertia of secod Drum
%---END of Values:------------------------------------------------------
%---START of Equation system:---------------------------------------------------
DY1DT = Y(2);
DY2DT = (Mv-(k*r1*(r1*Y(1)-r2*Y(3))))/I1;
DY3DT= Y(4);
DY4DT= (-k*r2*(r1*Y(1)-r2*Y(3))+r2*k*(r2*Y(3)-Y(5)))/I2;
DY5DT = Y(6);
DY6DT = (m*g-r2*k(r2*Y(3)-Y(5)))/m;
%---START of Equation system:---------------------------------------------------
% MAIN FUNCTION:
dyt = [DY1DT; DY2DT; DY3DT; DY4DT; DY5DT; DY6DT]
%use a row for calculations using ODE45 solver:
%[T, Y] = ode45('mokomasis2',[0 10],[0 0 0 0 0 0])
What am I doing wrong? Maybe i'm using a wrong example for solve my equation system? Also i tried to use different combination of system but still get more errors...
2 个评论
Rick Rosson
2014-8-21
回答(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!