call large equation to ode solver

조회 수: 9 (최근 30일)
shahin hashemi
shahin hashemi 2018년 6월 5일
댓글: Torsten 2018년 6월 5일
dear all
i want solve equation with using ode113
clc
clear all
tic
initialcond=[-0.001,-0.001,-0.001,-0.001,-0.001,-0.001]
[T X]=ode113(@solver2link,[0 40],initialcond);
toc
this is my ode file and the following file is my equation
function dy = shebhestatici1(t,y)
X1=y(1,1);
X2=y(2,1);X3=y(3,1);X4=y(4,1);X5=y(5,1);X6=y(6,1);
M
G
xdd=inv(M)*(-G);
dy=xdd;
end
i calculate M and G from different file
previously M and G are short equation and i could copy theme directly to my ode solver
but now after some changes it become large file and i cant copy them
so my question is how could i call them to my ode solver for example :
function dy = shebhestatici1(t,y)
X1=y(1,1);
X2=y(2,1);X3=y(3,1);X4=y(4,1);X5=y(5,1);X6=y(6,1);
function M G
xdd=inv(M)*(-G);
dy=xdd;
end
i know its wrong but just to clear my point
thank you all

채택된 답변

Torsten
Torsten 2018년 6월 5일
function dy = shebhestatici1(t,y)
X1=y(1,1);
X2=y(2,1);
X3=y(3,1);
X4=y(4,1);
X5=y(5,1);
X6=y(6,1);
M = function_where_you_supply_M(X1,X2,X3,X4,X5,X6);
G = function_where_you_supply_G(X1,X2,X3,X4,X5,X6);
xdd=-M\G;
dy=xdd;
end
  댓글 수: 5
shahin hashemi
shahin hashemi 2018년 6월 5일
i can change my code to a function but just with one output
function M = shebhestatici1
.
.
.
.
end
how should i do that for 2 ?
maybe like this ?
this doesnt work
function [M G] = shebhestatici1
and for last question should i put smth in front of shebhestatici1 ?
like :
function M = shebhestatici1(x)
Torsten
Torsten 2018년 6월 5일
https://de.mathworks.com/help/matlab/ref/function.html
In your case:
function [M,G] = shebhestatici1
If X1,...,X6 are needed to generate M and G,
function [M,G] = shebhestatici1(X1,X2,X3,X4,X5,X6)
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by