index exceeds matrix dimension

Hi i am new and would like some help on this. Appreciate if there is any answers to my question.
NumLoop=100;
ptFreq=[1:8:201];
ISUPPLY=[1:100];
VSUPPLY=[0.00001:0.00001:0.001];
for loop = 1 : NumLoop
I_BLA(loop,:) = ISUPPLY(loop,ptFreq+1)./VSUPPLY(loop,ptFreq+1);
end

回答(1 个)

Jan
Jan 2017-8-6
编辑:Jan 2017-8-6
E.g. ISUPPLY is a [1 x 100] vector:
ISUPPLY = 1:100;
ISUPPLY(loop, ptFreq+1)
tries to address a matrix with loop as the 1st dimension and ptFreq+1 as 2nd one. This worke only for loop=1 and ptFreq+1 is > 0 and <= 100. But ptFreq is 1:8:201. This means, that both indices are out of range during the loop.
The indexing of arrays is explained in the Getting Started chapters of the documentation exhaustively. Please read it again to understand the basics of Matlab.

此问题已关闭。

标签

关闭:

2021-8-20

Community Treasure Hunt

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

Start Hunting!

Translated by