Implementation of summation Matlab

2 visualizaciones (últimos 30 días)
Franzi
Franzi el 17 de Jun. de 2020
Comentada: Rena Berman el 12 de Oct. de 2020
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 comentarios
Franzi
Franzi el 17 de Jun. de 2020
I don't know, what should I use instead? only sum?
Rena Berman
Rena Berman el 12 de Oct. de 2020
(Answers Dev) Restored edit

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 17 de Jun. de 2020
Editada: Ameer Hamza el 18 de Jun. de 2020
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 comentarios
Franzi
Franzi el 18 de Jun. de 2020
thank you, it works now! :-)
Ameer Hamza
Ameer Hamza el 18 de Jun. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by