フィルターのクリア

Index exceeds the number of array elements (0)

2 ビュー (過去 30 日間)
ennes mulla
ennes mulla 2021 年 6 月 29 日
コメント済み: ennes mulla 2021 年 6 月 29 日
Hi, I have made a script to analyze image data. However, each time I run the script I get the following error message
Index exceeds the number of array elements (0).
Error in NewNormalScript (line 16)
FinalArray (q) = [aux(1)];
The script that i have made:
clear
clc
directory = 'C:\Users\anask\Desktop\New\CameraPhotos\';
b = zeros(3000,291);
FinalArray = zeros(1,291);
files = dir([directory '/*.jpg']);
[~,index] = sortrows({files.date}.'); files = files(index); clear index;
for q = 1:1:291
A= imread([directory '/' files(q).name]);
b(:,q) = A(:,2500,1);
aux = (find(b(:,q) >= 255));
FinalArray (q) = [aux(1)];
clear aux;
clc
end
I pretty confused with this problem. Can someone tell me what to do please?

採用された回答

Chunru
Chunru 2021 年 6 月 29 日
aux = (find(b(:,q) >= 255)); % This could be empty
if ~isempty(aux)
FinalArray (q) = [aux(1)];
end
  1 件のコメント
ennes mulla
ennes mulla 2021 年 6 月 29 日
% it worked perfectly! Thank you so much!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by