Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Subscript indices must either be real positive integers or logicals
조회 수: 1 (최근 30일)
이전 댓글 표시
getting this error when trying to build a set of data from a data store with the following code. I would like for every iteration of the for loop (one read from the data store), to add data to the table.
if true
clear
clc
ds = fileDatastore(fullfile('***example****);
tf = hasdata(ds);
i = 0
while (tf == 1);
accData(i,:) = read(ds); %read from datastore
tf = hasdata(ds);
i = i+1
end
thanks in advance
댓글 수: 0
답변 (3개)
Image Analyst
2017년 10월 23일
See the FAQ for a full explanation: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F
댓글 수: 0
Walter Roberson
2017년 10월 23일
You initialize i = 0, and then assign to accData(i,:) which tries to use that 0 as the index. You should do the i = i + 1 before using i as the index.
댓글 수: 0
Jeremy Hughes
2017년 10월 25일
Very common error. =) MATLAB arrays start at index = 1. You should see the same error from x(0,:) = 1.
In this case, I don't think you need the loop at all. Use the readall function:
accData = readall(ds)
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!