Array indices must be positive integers or logical values

 Respuesta aceptada

Star Strider
Star Strider el 17 de Nov. de 2019
Editada: Star Strider el 17 de Nov. de 2019
The problem:
for k=0:M-1
The solution:
for k=1:M
In MATLAB, subscript indices begin at 1, not 0, and are defined as integers greater than 0.
It is more efficient to do this without the loop:
H = cumsum(h* exp(-1i*2*pi*fd));
or simply:
H = sum(h* exp(-1i*2*pi*fd));

Más respuestas (1)

Your index k starts from 0 and you are indexing h with k, so you are asking at the first iteration h(0). Matlab has 1-indexing so you get the error. I guess your for loop should be
for k = 1:M
...
end

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 17 de Nov. de 2019

Editada:

el 17 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by