Implementation of summation Matlab

2 次查看(过去 30 天)
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?

请先登录,再进行评论。

采纳的回答

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 个评论

请先登录,再进行评论。

更多回答(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