Implementation of summation Matlab

조회 수: 2 (최근 30일)
Franzi
Franzi 2020년 6월 17일
댓글: Rena Berman 2020년 10월 12일
Hello! I have given a function , where a is a vector with n(n between 1 and 10) varaibles, e is the Eulerian number and x is a vector with 10 random values. I should now compute the following sum: , where y is also a vector with 10 random values. Can anyone help me to implement that please?
I have written this:
t=symsum((transpose(a(:)).*cos((1:n).*X(j)*e)-Y(j)).^2,j,1,11)
but it says this error: Array indices must be positive integers or logical values. The error is because one variable in my vector a is negative.
  댓글 수: 3
Franzi
Franzi 2020년 6월 17일
I don't know, what should I use instead? only sum?
Rena Berman
Rena Berman 2020년 10월 12일
(Answers Dev) Restored edit

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 17일
편집: Ameer Hamza 2020년 6월 18일
Try this
a = 1:10;
x = rand(1, 10);
y = rand(1, 10);
e = 1;
z = sum(a(:).*cos((1:numel(a)).'*x(:).'*e)-y(:).', 'all')
  댓글 수: 7
Franzi
Franzi 2020년 6월 18일
thank you, it works now! :-)
Ameer Hamza
Ameer Hamza 2020년 6월 18일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by