summation divided by summation

조회 수: 11 (최근 30일)
Onur Demir
Onur Demir 2017년 11월 28일
편집: per isakson 2017년 11월 29일
Hey, the beautiful pupil of the world. I'm trying to implant the formula below to MATLAB. I wrote the denominator and the numerator in different 'for' loops but it doesn't work like that. then, I tried to use special sum code but it didn't work either. so, could you help me to solve this problem?
here is the code I used;
a=2;
l=2;
d1= (sum(l,l,0,l))*(r1.^a)./(sum(r1.^a,l,0,l));
d2= (sum(l,l,0,l))*(r2.^a)./(sum(r2.^a,l,0,l));
thanks in advance.
  댓글 수: 9
Jan
Jan 2017년 11월 28일
@Onur: Did you consider the advice concerning "sum"? sum() is a built-in function, but calling it like sum(l,l,0,l) is not valid. If your "sum" is a user-defined function, use a different name, because shadowing important built-in functions is not an error, but very confusing.
Onur Demir
Onur Demir 2017년 11월 28일
Everyone, I'm really appreciated that you helped me. I finally find my mistakes and solve them. Now I have another problem. If you want to help me, please check this page; https://www.mathworks.com/matlabcentral/answers/369732-implementation-of-the-cross-correlation

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 11월 28일
Change your / to ./
And you should probably have about 30 or 40 lines of comments explaining in detail why you feel it is necessary to name your variable or custom function sum in conflict with the standard MATLAB function sum()
  댓글 수: 1
Onur Demir
Onur Demir 2017년 11월 28일
편집: per isakson 2017년 11월 29일
Walter, I'm really appreciated that you helped me. I finally find my mistakes and solve them. Now I have another problem. If you want to help me, please check this page; https://www.mathworks.com/matlabcentral/answers/369732-implementation-of-the-cross-correlation

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by