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 个评论

请先登录,再进行评论。

采纳的回答

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 个评论

请先登录,再进行评论。

更多回答(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