Struct contents reference from a non-struct array object. Error in last two line

%%path stuff
if nargin < 2
model_save_path = uigetdir('.models','Select model save folder');
positive_images_path = uigetdir('.images','Select positive image folder');
negative_images_path = uigetdir('.images','Select negative image folder');
if isa(model_save_path,'double') || ...
isa(positive_images_path,'double') || ...
isa(negative_images_path,'double')
cprintf('Errors','Invalid paths...\nexiting...\n\n')
return
end
else
model_save_path = paths{1};
positive_images_path = paths{2};
negative_images_path = paths{3};
end
%%train matrix and labels
params = get_params('train_svm_params');
pos = params.num_positive_instances;
negs = params.num_negative_instances;
[positive_images,negative_images] = ...
get_files(pos, negs,{positive_images_path,negative_images_path});
[labels, train_matrix]= get_feature_matrix(positive_images,negative_images);

3 Comments

@Rahul Kumar: please show us the complete error message. This means all of the red text.
Rahul Kumar's "Answer" moved here:
Here it is @Stephen Cobeldick
Struct contents reference from a non-struct array object.
Error in get_feature_matrix (line 44)
I = imread(positive_images(i).name);
Error in train_svm_PCA (line 45)
[labels, train_matrix]= get_feature_matrix(positive_images,negative_images);
Well, clearly the function get_feature_matrix expects its internal variable positive_images to be a structure, but it isn't.
Apparently you used the same names for the input arguments as get_feature_matrix uses internally, which would indicate that the function get_files did not return the required structure. As you did not provide us with either function, we cannot investigate why this is the case. I would speculate that the path or files were not found, or the expected file contents were not obtained, but without those functions this is all just guesswork...
If you want more help please upload in a comment (not an answer) the functions get_files and get_feature_matrix (click the paperclip button to upload files).

Answers (0)

This question is closed.

Asked:

on 30 Jun 2018

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!