필터 지우기
필터 지우기

Error when using the function ODE45

조회 수: 3 (최근 30일)
Stephanie Velasco
Stephanie Velasco 2017년 2월 24일
편집: Walter Roberson 2017년 2월 25일
I have written to the following function to solve a differential equation using ODE 45, but i always seem to come across an error saying the "Inputs must be floats, namely single or double.". I am trying to solve for dt/dx,t(x)= 1/(a*x^(0.6)-b*x)), to find the time. but i get an error every time. since I have x in the equation idk what I'm doing wrong.
script
x_interval=[0.5 10];
t0 = [0];
[x,t] = Ode45(diff_,x_interval,t0);
function dt/dx = diff_(x,t)
a = 10;
b=0.5;
syms x;
t = (1/(a*x^(0.6)-b*x));
dt_dx =t;
end
  댓글 수: 2
John D'Errico
John D'Errico 2017년 2월 24일
How is this question significantly different from the last time you asked it, asking for help on solving the same question? Please stop making multiple postings for the very same problem.
Stephanie Velasco
Stephanie Velasco 2017년 2월 25일
I wasn't sure if this one was clear enough, Im sorry about that. Have a blessed day

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

채택된 답변

John Chilleri
John Chilleri 2017년 2월 25일
Hello,
You just need to change a few things:
Script - missing an @ symbol.
x_interval=[0.5 10];
t0 = 0;
[x,t] = ode45(@diff_,x_interval,t0);
Function - don't use sym and you have a / in the name.
function dt_dx = diff_(x,t)
dt_dx = (1/(10*x^(0.6)-.5*x));
end
I simplified your function, but you can leave it as,
function dt_dx = diff_(x,t)
a = 10;
b=0.5;
t = (1/(a*x^(0.6)-b*x));
dt_dx =t;
end
Hope this helps!
  댓글 수: 1
Stephanie Velasco
Stephanie Velasco 2017년 2월 25일
Thank you so much! Have a great day!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by