Array indices must be positive integers or logical values.

9 views (last 30 days)
Mawarni Bagasta Simanjuntak
Answered: Walter Roberson on 5 Jul 2022
Nt=4;
syms t;
syms H1;
H1= 1/Nt(symsum(hd,t,1,Nt))
H2= 1/Nt(symsum(hk,1,Nt))
Array indices must be positive integers or logical values.
please help to resolve this code

Answers (1)

Walter Roberson
Walter Roberson on 5 Jul 2022
Remember that MATLAB has no implied multiplication, so your code is asking to take 1 divided by (Nt indexed at something), where you probably meant (1 divided by Nt) times something
Note: there is no documented syntax for symsum() with three inputs -- only four inputs or two inputs. In each case, the first input needs to be a symbolic function or symbolic expression, and the second input needs to be the symbolic variable to take the summation over.
If your hd or hk are vectors of length Nt that you are wanting to sum, do not use symsum() for that: just use sum(). symsum() is for the case where you are hoping to find formulaes for the summation, such as if you input the expression for the taylor series of a function and you are hoping to identify the function.

Community Treasure Hunt

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

Start Hunting!