MATLAB Answers

Error "Undefined function or variable"

3 views (last 30 days)
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 Comments
Cris LaPierre
Cris LaPierre on 18 Sep 2021
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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Sep 2021
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 Comments
Paun Jovanovic
Paun Jovanovic on 20 Sep 2021
Problem solved. Thank you so much!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!