MATLAB Answers

Implementation of summation Matlab

3 views (last 30 days)
Franzi
Franzi on 17 Jun 2020
Edited: Franzi on 18 Jun 2020
This question was flagged by madhan ravi
Hello!

  2 Comments

KSSV
KSSV on 17 Jun 2020
Why to use symsum when all the variables are known?
Franzi
Franzi on 17 Jun 2020
I don't know, what should I use instead? only sum?

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 17 Jun 2020
Edited: Ameer Hamza on 18 Jun 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 Comments

Show 4 older comments
Ameer Hamza
Ameer Hamza on 18 Jun 2020
The problem happened because I assumed x and y are row matrices, whereas they can be column matrix too. I have modified my answer to work with both cases.
Franzi
Franzi on 18 Jun 2020
thank you, it works now! :-)
Ameer Hamza
Ameer Hamza on 18 Jun 2020
I am glad to be of help!

Sign in to comment.

More Answers (0)

Tags