I am observing below error. Can anyone help me in order in troubleshooting this ?. Code is also shared below for reference.
Reference to non-existent field 'names'.
Error in ab (line 24)
names = {pos.names{:}, neg.names{:}};
code:
% add the required search paths
setup ;
% --------------------------------------------------------------------
% Stage A: Data Preparation
% --------------------------------------------------------------------
% Load training data
%pos = load('data/aeroplane_train_hist.mat') ;
%pos = load('data/motorbike_train_hist.mat') ;
%pos = load('data/car_train_hist.mat') ;
v = implay('data/images/multiple.avi');
x = v.Visual.Image.CData;
save multiple;
pos = load('data/multiple_fast_hist.mat');
%pos = load('data/person_train_hist.mat') ;
%neg = load('data/background_train_hist.mat') ;
d = implay('data/images/a.avi');
y = d.Visual.Image.CData;
save a;
neg = load('data/a_motorway_hist.mat');
names = {pos.names{:}, neg.names{:}};
histograms = [pos.histograms, neg.histograms] ;
labels = [ones(1,numel(pos.names)), - ones(1,numel(neg.names))] ;
clear pos neg ;

댓글 수: 5

Syed - put a breakpoint at the line
pos = load('data/multiple_fast_hist.mat');
and then run your code. When the debugger pauses at this line, step over it to see what gets assigned to pos. Given the error message, it sounds like there isn't a field called names. Is that the case?
Geoff Hayes
Geoff Hayes 2018년 4월 3일
Syed's answer moved here
Dear Geoff; thanks for your valuable feedback.
Yes, names is not a field.
I have again run this code; and observed that value in pos when debugger stop; it seems that it is not loading values properly from .mat file.
Geoff Hayes
Geoff Hayes 2018년 4월 3일
Syed - how is the data being loaded? What does it look like?
Stephen23
Stephen23 2018년 4월 3일
SYED OSAMA AFZAL's "Answer" moved here:
Dear Geoff, pos is reflecting as an structure array,which have seven fields.
I think that my data size is too large due to which it is giving error.
Can you please confirm me, whether there is any parenthesizes problem in below line ?.
names = {pos.names{:}, neg.names{:}};
Stephen23
Stephen23 2018년 4월 3일
@SYED OSAMA AFZAL: please use the comments for commenting. The answers are for answering the question.

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

답변 (1개)

Guillaume
Guillaume 2018년 4월 3일

0 개 추천

Well, the problem is easy to troubleshoot. For these lines to work:
pos = load('data/multiple_fast_hist.mat');
neg = load('data/a_motorway_hist.mat');
names = {pos.names{:}, neg.names{:}};
both mat files multiple_fast_hist.mat and a_motorway_hist.mat must contain a variable called names. If they do not, then you'll get a Reference to non-existent field 'names' error.
So clearly, your mat files do not have that variable. We obviously can't tell you how to fix it. Either you need to modify your current code so that it doesn't need the variables to exist or you need to go back to the code that initially created those mat files so that it creates and saves these names variables.

카테고리

질문:

2018년 4월 2일

답변:

2018년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by