Why am I getting "Undefined function or variable" when I use an exponential in the function?
조회 수: 1 (최근 30일)
이전 댓글 표시
My code worked for other functions, but as soon as I use the exponential function, I am getting an error saying that "I" is undefined, and I honestly have no idea why it's giving me an error only for the exponential function.
a = 0;
b = 1;
N = 10;
f = @(x) exp(-x);
h=(b-a)/N;
j = 0;
x=linspace(a,b,N);
for i = 1:N-1
j=j+f((2*i+1)/2)*x;
end
answer1 = sum(I)
댓글 수: 0
답변 (1개)
James Tursa
2019년 4월 11일
There is no "I" variable in your code. Hence the error.
댓글 수: 5
James Tursa
2019년 4월 11일
What does the exponential have to do with your problem of "I" not being defined?
John D'Errico
2019년 4월 11일
I wonder if it is possible Nocholas has created a script of function named exp?
참고 항목
카테고리
Help Center 및 File Exchange에서 Probability Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!