What was that problem?

조회 수: 8 (최근 30일)
Lan
Lan 2015년 2월 10일
댓글: Lan 2015년 2월 10일
Matlab:edit,then add the the following values in a m.file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dx=myfun(t,x)
dx(1)=-6*x(2)*x(2)-9;
dx(2)=-3*x(1)*x(2)-2*x(3)-Yvv-Yuu;
dx(3)=x(1)*x(2)+x(3)+8;
Yvv=0.5*p*L*T*(0.048265-6.293*(1-c)*T/B);
Yuu=0.5*p*L*L*L*T*(0.0045-0.445*(1-c)*T/B);
dx=dx(:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Finally,, Matlab :
clear all
clc
syms Yvv Yuu p L T c T B
x0=[1,1,1];
t0=0:0.1:2;
[t,x]=ode45('myfun',[0,10],x0); %ode45会自动调整步长
plot(t,x)
legend('u','v','Y')

채택된 답변

Torsten
Torsten 2015년 2월 10일
Try
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dx=myfun(t,x)
p=1;
L=1;
T=1;
c=1;
B=1;
Yvv=0.5*p*L*T*(0.048265-6.293*(1-c)*T/B);
Yuu=0.5*p*L*L*L*T*(0.0045-0.445*(1-c)*T/B);
dx(1,1)=-6*x(2)*x(2)-9;
dx(2,1)=-3*x(1)*x(2)-2*x(3)-Yvv-Yuu;
dx(3,1)=x(1)*x(2)+x(3)+8;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
clc
x0=[1,1,1];
t0=0:0.1:2;
[t,x]=ode45('myfun',[0,10],x0); %ode45会自动调整步长
plot(t,x)
legend('u','v','Y')
Best wishes
Torsten.
  댓글 수: 3
Torsten
Torsten 2015년 2월 10일
Because you have to give numerical values to them instead of defining them as symbolic variables. ODE45 can not handle symbolic variables.
Best wishes
Torsten.
Lan
Lan 2015년 2월 10일
There are another two questions, would you help me ?

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

추가 답변 (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