Solving ODE45 equations in matlab without a function
显示 更早的评论
I am struggling to figure out what is wrong with my code please help.
%%Numerically solving for Trajectory of the Ball in a Vacuum
clc
v0=25;
% Average football is punted at 25 m/s
theta=35;
% Chosen value for the angle of a punt
g = 9.8;
t=2.5;
t2 = 1.25;
CF = [.3 .385];
y0 = 0;
xdist = v0*cosd(35)*t;
yheight = (-.5*(g*(t2^2)))+v0*sind(theta)*t2;
% A ball punted with these variables would travel 51.2 meters horizontally
% and the max height would be 10.27 meters
x = zeros(1,2);
y0 = zeros(1,2);
t = [0 2.5];
[t,x] = ode45(@(t,x) (v0*cos(theta)*exp(-CF*t)), t, y0)
--------------------------------------
and I am receiving the errors:
Error using odearguments (line 90)
@(T,X)(V0*COS(THETA)*EXP(-CF*T)) must return a column vector.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!