MATLAB Answers

How to solve ode functions?

2 ビュー (過去 30 日間)
Danny Maefengea
Danny Maefengea 2020 年 9 月 16 日
コメント済み: Danny Maefengea 2020 年 9 月 16 日
Hi there,
Please see my code which is attached here. I have tried to run it, but it says not enough inputs.
Can anyone help me with this?
Thank you very much for your help.

  2 件のコメント

Stephen Cobeldick
Stephen Cobeldick 2020 年 9 月 16 日
You defined a function in a script. The function requires two inputs arguments:
function [velocity, time]= diff_eqn(t1,depth)
When you called the function, did you provide it with both of those inputs?
Danny Maefengea
Danny Maefengea 2020 年 9 月 16 日
No Sir.
Can you guide me through how to put in the inputs?

サインインしてコメントする。

採用された回答

BOB MATHEW SYJI
BOB MATHEW SYJI 2020 年 9 月 16 日
From question, I guess the inputs should be velocity and depth of the container. The outputs should be time taken to reach the required velocity (t1) and time taken to reach the bottom of the container (time). I have created the function Velo_ball(velocity,depth) which inputs the velocity and depth as input and gives the output t1=time at which given velocity is acheived and time= time to hit the bottom of container. Hope this helps. If not please rectify.
function [t1, time]= Velo_ball(velocity,depth)
syms y(t)
ode = diff(y)+0.025*y^2==1.6;
cond=y(0)==0;
v=dsolve(ode,cond,t);
S= v==velocity;
t1=double(solve(S,t))
time=depth/velocity
end

  1 件のコメント

Danny Maefengea
Danny Maefengea 2020 年 9 月 16 日
Thank you Sir.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by