matlab ODE45

来源:百度知道 编辑:UC知道 时间:2024/05/08 03:51:39
第一次编matlab
实在不知道错在哪里,救命啊!1

function a=weifen(t,y)
v=1000;x=pi/6;g=9.8;
a=[v*cosx;v*sinx-g.*t];保存为WEIFEN.M

t=[0,100];
h=500;
y0=[0;h];
[t,y]=ode45(@weifen,t,y0);
plot(t,y);大虾最好能仔细点,本人很菜!

这下子就通了:
%==============
function hahaha
clc;clear;
t=[0,100];
h=500;
y0=[0;h];
[t,y]=ode45(@weifen,t,y0);
plot(t,y);
function a=weifen(t,y)
v=1000;x=pi/6;g=9.8;
a=[v*cos(x);v*sin(x)-g*t];
%=====================

或者:
%====================
clc;clear;
t=[0,100];
h=500;
y0=[0;h];
v=1000;x=pi/6;g=9.8;
weifen=@(t,y) [v*cos(x);v*sin(x)-g*t];
[t,y]=ode45(weifen,t,y0);
plot(t,y);
%====================