MATLAB: Trouble with inline functions.

backwards compatibilityinline()MATLABobsoleteode45outdated

My homework says to use this code:
f = inline('[x(2);-sin(x(1))]', 't' , 'x');
xystart = [2 1]; tEnd=30;
[t,xa] =ode45(f,[0,tEnd],xystart);
k2 = min(find(t>2))
xa(k2,:)
as an example of how to solve a systme of differential equations, but I'm using using version R2019b and the assignment directions were written for an older version.
When I use the code from the instructions MATLAB throws this error:
Error using inline/horzcat (line 7)
Inline functions can't be concatenated.
Error in odefcncleanup (line 15)
[~,oldFcnFun] = evalc(['@' oldFcn]);
Error in ode45 (line 274)
odeFcn_main = odefcncleanup(FcnUsed,odeFcn,odeArgs);
Error in project5_task13 (line 4)
[t,xa] =ode45(f,[0,tEnd],xystart);
This is the first time I've seen the "inline" command so I'm not sure what it's trying to do much less how to fix it.
Please help.
Thank you.

Best Answer

inline is replaced by handles function:
f = @(t,x) [x(2);-sin(x(1))];
xystart = [2 1]; tEnd=30;
[t,xa] =ode45(f,[0,tEnd],xystart);
k2 = min(find(t>2))
xa(k2,:)
Related Question