Error "Undefined function or variable"
조회 수: 3 (최근 30일)
이전 댓글 표시
I am receiving one of the following error messages. How can I resolve this issue?
Undefined function or variable 'segment_list'.
Code:
labels = {'cheduepalle';'fame';'chevuoi';'basta'};
segment_counter = 1;
for data_counter=1:num_of_samples
currVideo = data_files(data_counter).Video;
for label_counter = 1: length(currVideo.Labels)
if ismember(currVideo.Labels(label_counter).Name, labels)
s = struct('videoID', data_counter, 'start',currVideo.Labels(label_counter).Begin, 'end', currVideo.Labels(label_counter).End, 'label', currVideo.Labels(label_counter).Name);
segment_list(segment_counter) = s;
segment_counter = segment_counter + 1;
end
end
end
댓글 수: 3
Cris LaPierre
2021년 9월 18일
It looks like segment_list never gets created. This could be because your for loops never end up running, or because your if conditional is never true. See Walter's reply below for more details.
채택된 답변
Walter Roberson
2021년 9월 18일
Perhaps num_of_samples is less than 1.
Perhaps data_files(data_counter).Video is empty for all num_of_samples different videos.
Perhaps none of the labels on any of the videos exactly match any of the values in the variable labels
댓글 수: 2
Walter Roberson
2021년 9월 18일
Right after you assign to the variable labels do
segment_list = struct('videoID', [], 'start', [], 'end', [], 'label', []);
This will initialize segment_list to an empty structure with the required fields.
Then if any of the "Perhaps" that I listed above hold true, then at least segment_list will be defined.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!