質問には英語でお答えしますのでご了承ください。
(Please note that I will be answering the question in English. )
Hi,
I understand that you are trying to solve second-order ODE and would like to use the MATLAB function ode45 for the same. But you are getting an error "Function or variable not recognized." in your code.
In the cal_a function, you created a variable dydt which you are trying to pass as a function handle to ode45. Instead, you should define a function which gives output as dydt and pass the function handle as input, the first input argument of ode45 is a function handle, not a variable.
Refer to this following documentation which has an example to pass the first argument to the function ode45:
For your case, create a function as follows:
function dydt = odefun(t,y,f)
dydt = [y(2); f(y(1),y(2),t)];
Then pass the handle as input to ode45:
[t,y] = ode45(@odefun,tspan,[R; RV]);
I hope this helps.
Regards,
Aiswarya