フィルターのクリア

Solving system of second order differential equations

3 ビュー (過去 30 日間)
karthik madhamshetty
karthik madhamshetty 2018 年 3 月 30 日
コメント済み: Torsten 2018 年 4 月 4 日
Hi,
I tried to solve a system of coupled differential equations.
Can anyone help me with this error?
"Error using odearguments (line 93) ODE_FUNCTION must return a column vector.
Error in ode23tb (line 135) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in ODE_Function_Solver (line 4) [t,y] = ode45(@ODE_Function,tspan,y0);"
Thank you.
tspan = 0:0.001:2;
y0 = [0 0;0 0;0 0;0 0;0 0;0 0];
[t,y] = ode23tb(@ODE_Function,tspan,y0);
function dydt = ODE_Function(t,y)
m1 = 1;
k1 = 100;
m2 = 1;
k2 = 100;
w = 2*pi*50;
F = sin(w*t);
h = 0.1;
w = 0.1;
% First ODE
dydt(1) = y(2);
dydt(2) = F - k1/m1*(y(1)-y(5))-2*k2/m1*cos(atan((2*h-2*y(3))/w))*(y(1)-y(3));
% SecondODE
dydt(3) = y(4);
dydt(4) = -2*k2/m2*cos(atan((2*h-2*y(3))/w))*(y(3)-y(1));
% Third ODE
dydt(5) = y(6);
dydt(6) = -k1/m1*(2*y(5)-y(1)-y(9))-2*k2/m1*cos(atan((2*h-2*y(7))/w))*(y(1)-y(3));
% Fourth ODE
dydt(7) = y(8);
dydt(8) = -2*k2/m2*cos(atan((2*h-2*y(7))/w))*(y(7)-y(5));
% Fifth ODE
dydt(9) = y(10);
dydt(10) = -k1/m1*(y(9)-y(5))-2*k2/m1*cos(atan((2*h-2*y(11))/w))*(y(1)-y(3));
% Sixth ODE
dydt(11) = y(12);
dydt(12) = -2*k2/m2*cos(atan((2*h-2*y(11))/w))*(y(11)-y(9));

採用された回答

lokender Rawat
lokender Rawat 2018 年 4 月 4 日
The return type of the parameter from the function block must be a column vector. So, you can add the below statement at the end, inside the function block:
dydt=dydt';
I think you were missing this.
  1 件のコメント
Torsten
Torsten 2018 年 4 月 4 日
... and you shouldn't supply y0 as a (6x2) matrix, but as a (12x1) vector.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by