CalculateIntegral (2,5)을 MATLAB 명령 창에 입력하면 다음과 같은 오류가 발생합니다.MATLAB 오류 메시지 (함수 정의)
??? 오류 : 파일 : CalculateIntegral.m 줄 : 2 열 : 1 함수 정의는 프롬프트 나 스크립트에서 허용되지 않습니다.
이 오류를 해결하는 방법을 모르겠습니다. 감사.
clear all;
function g = CalculateIntegral(s,N)
a=0;
b=1;
h=(b-a)/N;
x = 0:h:1;
g = ff(x).*exp(-s*x);
% compute the exact answer of the integral
exact_answer=antiderivative(b,s)-antiderivative(a,s);
% compute the composite trapezoid sum
If=0;
for i=1:(N-1)
If=If+g(i)*h;
end;
If=If+g(1)*h/2+g(N)*h/2;
If;
지금 실행할 때 벡터가 출력되는 이유는 무엇입니까? 나는 모든 후 세미콜론 있습니다. – icobes
질문에서 코드를 삭제 한 이유는 무엇입니까? –
코드와 함께 다른 질문을 게시했습니다. – icobes