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

조회 수: 2 (최근 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!