입력 인수가 부족합니다 나옵니다

5 次查看(过去 30 天)
관호 송
관호 송 2022-3-29
回答: Binaya 2023-10-20
어디서 잘못된것인지 잘 모르겠습니다
function dx= msd(x,u)
dx=[x(2); (a22*(u-g1)+a12*g2)/det];
end
이건 msd함수의 코드입니다

回答(1 个)

Binaya
Binaya 2023-10-20
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:
  1. 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.
  2. To execute the code without any other issues please also implement the below modifications in the code.
  3. 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.
  4. 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
  1. 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:
  1. Ode45: https://www.mathworks.com/help/matlab/ref/ode45.html
  2. Function Handle: https://www.mathworks.com/help/matlab/ref/function_handle.html
I hope this helps.
Regards 
Binaya

类别

Help CenterFile Exchange 中查找有关 상미분 방정식 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!