Problem with symsum: not working with vector of matrix elements

2 views (last 30 days)
Help Plz, I want to calculate summation from 1 to j of (x(6,k).*dz./sin((pi/180).*atan((pi/180).*x(6,k))), but no results
Note that Pas(j)=j with j =1:nz-1; nz= a number
Thank's for any answer !!

Accepted Answer

Walter Roberson
Walter Roberson on 10 Jan 2020
It is never possible to use a symbolic variable as an index into an array. You should just calculate the expression in vectorized form outside of symsum and then sum() them.

More Answers (1)

Steven Lord
Steven Lord on 10 Jan 2020
If I understand what you're trying to do correctly, symsum is the wrong tool to use because you're trying to use that variable of summation as indices into a variable. Instead just use sum, something like:
>> x = 1:10;
>> syms dz
>> sY = sum(x.*dz./sin((pi/180).*atan((pi/180)*x)))
The degree-based trigonometry functions like sind and atand functions may also be of interest to you.

Community Treasure Hunt

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

Start Hunting!