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 Comment

You forgot to ask a question.

Answers (1)

Jan
Jan on 6 Aug 2017
Edited: Jan on 6 Aug 2017
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.

This question is closed.

Tags

Asked:

on 6 Aug 2017

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!