Array indices must be positive integers or logical values.

1 view (last 30 days)
I am getting above error.
where dataout =1586*128 double
Fabio Freschi
Fabio Freschi on 9 Sep 2019
true, but the error pointed out by the OP is about wrong indexing

Sign in to comment.

Answers (2)

Stephen23 on 9 Sep 2019
Edited: Stephen23 on 9 Sep 2019
Check your indexing:
>> colum = 128;
>> dtn = 129;
>> colum-dtn+1
ans = 0
MATLAB indexing start at 1.

TADA on 9 Sep 2019
in Matlab, matrix indices start from one, not zero like other programming languages, but your index starts from zero:
colum-dtn+1 = 0
so what you are actually doing is this:
I guess what you did try to do is more like copy the entire row of data_in_temp into the i'th row of data_out?
if so, try this:
data_out(i,:) = data_in_temp
or if you are trying to copy a subset of that row, make sure the index of data_in_temp is the same size as that of data_out

Community Treasure Hunt

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

Start Hunting!