Array indices must be positive integers or logical values
Show older comments
H = 0;
M = length(h);
for k=0:M-1
H = H + (h(k) * exp(-1i*2*pi*fd));
end
%fd and h come from a function call
Accepted Answer
More Answers (1)
Fabio Freschi
on 17 Nov 2019
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
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!