Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Why this code is error???
조회 수: 1 (최근 30일)
이전 댓글 표시
clc,clear all,close all;
x = [0 1 2 3];
y = [0 1 2 3];
f3 = 6./(factorial(x).*factorial(3-x));
f4 = 24./(factorial(y).*factorial(4-y));
f5 = 120./(factorial(3+(-x)+(-y)).*factorial(2+x+y));
mpd = (f3.*f4.*f5)./220;
stem3(x,y,mpd);
xlabel('x'); ylabel('y'); zlabel('mpd');
댓글 수: 2
RB Blackstone
2018년 2월 16일
This part of the equation produced negative integers.
>> 3+-x+-y
Ans = 3 1 -1 -3
Factorial() requires non-negative integers.
답변 (1개)
C.J. Harris
2018년 2월 15일
Because given your definitions of x and y, the expression 3+(-x)+(-y) results in [3 1 -1 -3], and you cannot calculate the factorial of a negative number.
댓글 수: 2
Jan
2018년 2월 16일
@Jukkrid Boonlkom: How could the readers know, what you want to do. All we see is the failing code, which cannot work for mathematical reasons. This does not allow to suggest a modification, because you did not tell yet, what you want to calculate.
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!