i was given these equations to solve with ode15s ( dy(1)=y(2), dy(2)=0, dy(3)=y(4), dy(4)=-g), initial conditions y(1)=0, y(2)=v(cosa), y(3)=0, y(4)=v(sina) but it keeps telling me i dont have enough input arguments

function dy = func(t,y,g,v,a)
dy=zeros(4,1)
g=9.81
v=10
a=45
dy(1)=y(2)
dy(2)=0
dy(3)=y(4)
dy(4)=-g
[t,y]=ode15s(@func, [0 20], [0 v*cos*a 0 v*sin*a])
plot(y(:,1),y(:,3))

1 Comment

function df
global g v a
g=9.81
v=10
a=45
t=linspace(1,20)
[t,y]=ode15s(@func, [0 20], [0 v*cos(a) 0 v*sin(a)])
figure(1)
hold on
plot(y(:,1),y(:,3))
function dy = func(t,y)
dy=zeros(4,1)
% g=9.81
% v=10
% a=45
dy(1)=y(2)
dy(2)=0
dy(3)=y(4)
dy(4)=-g
end
end

Sign in to comment.

Answers (1)

what is this
[0 v*cos*a 0 v*sin*a]
do you mean?
[0 v*cos(a) 0 v*sin(a)]
%your function
function dy = func(t,y)
dy=zeros(4,1)
g=9.81
v=10
a=45
dy(1)=y(2)
dy(2)=0
dy(3)=y(4)
dy(4)=-g
then call func
g=9.81
v=10
a=45
[t,y]=ode15s(@func ,[0 20], [0 v*cos(a) 0 v*sin(a)])

Categories

Asked:

on 19 Jun 2013

Commented:

on 25 Oct 2023

Community Treasure Hunt

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

Start Hunting!