Hi 관호 송,
Based on my understanding, you would like to resolve the error in the provided code. Upon reviewing the given code, it appears that the initial error has been resolved. However, subsequent errors have arisen, indicating that certain variables used within the "msd" function are undefined.
Please follow the below steps to resolve all the issues inside the code:
- To resolve the initial error of “Not enough input arguments”, please follow the documentation of the “ode45” which requires a function handle and not a function as the first argument.
- To execute the code without any other issues please also implement the below modifications in the code.
- Move line number 3 to line number 19 in the current code inside the “msd” function. Change the variable names of “x(1)” to “x(4)” to remove any variable with same names.
- Make the following changes in the “msd” function:
function dx = msd(t,x) %Line number 1 in msd function
dx=[x(2); (a22*(t-g1)+a12*g2)/det]; %dx definition inside msd function
- Change the “ode45” function call to the following:
[t,y]=ode45(@msd,[0 10],[x(1);x(2)])
Please refer to the below Mathworks documentation for more details:
- Ode45: https://www.mathworks.com/help/matlab/ref/ode45.html
- Function Handle: https://www.mathworks.com/help/matlab/ref/function_handle.html
I hope this helps.
Regards
Binaya