matlab y=x^2 的数值解怎么编 不要原函数的那种

y‘=x^2 (标题打错了)

m文件
function y=yfun(x)
y‘=x^2

[t,x]=ode45('yfun',[0 1],0)

哪个地方错了
求指出

function dy=yfun(x,y)
dy=x^2;

[X,Y]=ode45('yfun',[0 1],0)

错误为:中文括号
yfun要有两个变量
变量不会有y'=追问

谢谢
matlab是如何判断是求哪个函数的原函数的呢?
[X,Y]=ode45('yfun',[0 1],0) 此式中的X,Y哪个是自变量?哪个是函数

小白
实在不理解 [X,Y]=ode45('yfun',[0 1],0) 中 X Y 的含义

追答

其实都在help里
引用如下:
Syntax
[t,Y] = solver(odefun,tspan,y0)
[t,Y] = solver(odefun,tspan,y0,options)
[t,Y,TE,YE,IE] = solver(odefun,tspan,y0,options)
sol = solver(odefun,[t0 tf],y0...)

where solver is one of ode45, ode23, ode113, ode15s, ode23s, ode23t, or ode23tb. ArgumentsThe following table describes the input arguments to the solvers. odefun
A function that evaluates the right side of the differential equations. All solvers solve systems of equations in the form y'=f(t,y) ...
所以y是所求,第一个变量默认为变量

温馨提示:答案为网友推荐,仅供参考
大家正在搜