필터 지우기
필터 지우기

how to solve the error array indices must be positive indices or logical values.

조회 수: 1 (최근 30일)
the error i am getting: Array indices must be positive integers or logical values.
Error in get_im_label (line 14)
if ~strcmp(dataname(j).name(end-1:end),'db') % ËÎ
Error in demo_CURET (line 25)
imageDatasetLabel = get_im_label(imdir);
how to solve this? i have attached my code with this.
  댓글 수: 3
Shan Sha
Shan Sha 2018년 10월 12일
the value of j is 486 when the error occurs
Kevin Chng
Kevin Chng 2018년 10월 12일
how about (end-1:end), any possible that it is negative value (end-1)?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 10월 12일
Your directory contains a name that is one character long. For example your code is not accounting for the . entry you will find in most file systems.
  댓글 수: 3
Kevin Chng
Kevin Chng 2018년 10월 12일
Some of your file might have only one character, so name(end-1:end) become name(0:1)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Steven Lord
Steven Lord 2018년 10월 12일
If that section of code is intended to check that the file has the extension db, instead call fileparts on the filename then use isequal, strcmp, etc. to test if the third output matches .db.

Image Analyst
Image Analyst 2018년 10월 12일
Try this:
if endsWith(dataname(j).name,'db','IgnoreCase',true)
% filename ends with 'db'
else
% Filename does not end with 'db'
end
endsWith() requires R2016b or later.
  댓글 수: 3
Image Analyst
Image Analyst 2018년 10월 14일
Then you should be ok. So replace all that complicated code of yours with the code I gave you.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by