Undefined function 'min' for input arguments of type 'struct'.
古いコメントを表示
Undefined function 'min' for input arguments of type 'struct'.
Error in mapminmax.create (line 12)
xmin = nnet.array.safeGather(min(x,[],2));
Error in mapminmax (line 51)
[y,settings] = mapminmax.create(x,param);
Error in GLCM_MainTotalDemo (line 46)
P_train=mapminmax(P_train,0,1);
%********* program **************************
clear all;
clc;
%% BUILD DORSAL HAND VEIN TEMPLATE DATABASE
tic; %% calculating elapsed time for execution
%% load mat files
load('db5.mat');
load('db6.mat');
%% reshape into row vector
reduced_testdata = reshape(reduced_testdata,1,4,10); % one row,four column and 15(60/4) group for 20 classes
reduced_traindata = reshape(reduced_traindata,1,4,20); % one row,four column and 45(180/4) group for 20 classes
%% adjust dimension
% Adjust matrix dimension
P_test = cell2mat(reduced_testdata); % Convert cell array to matrix
P_train = cell2mat(reduced_traindata);
%% rearranges the dimensions of P_test and P_train
C = permute(P_test,[1 3 2]);
P_test = reshape(C,[],size(P_test,2),1);
C = permute(P_train,[1 3 2]);
P_train = reshape(C,[],size(P_train,2),1);
%% labeling class
train_label=load('train_label_2.txt');
test_label=load('test_label_2.txt');
% %%% Normalisation
%
% P_train=P_train/256;
% P_test=P_test/256;
%% Normalisation by min max
P_train=mapminmax(P_train,0,1);
P_test=mapminmax(P_test,0,1);
%% %%PCA low dimension reduction
P_train = P_train';
%%% if classes are 20 then eiganvectors not exceed then 179
model = perform_pca(P_train,rank(P_train)-1); %rank(P_train)-1
test_features= linear_subspace_projection(P_test, model, 1);
P_train=model.train';
P_test=test_features';
%% classfication
predictlabel = knnclassify(P_test, P_train, train_label,3,'euclidean','nearest');
cp = classperf(test_label,predictlabel);
Conf_Mat = confusionmat(test_label,predictlabel);
disp(Conf_Mat);
[c_matrix,Result,RefereceResult]= confusion.getMatrix(test_label,predictlabel);
%% % Evaluate Performance
[FPR, TPR,Thr, AUC, OPTROCPT] = perfcurve(predictlabel, test_label,1);
figure,
plot(TPR,FPR,'r-','LineWidth',1);
xlabel('False positive rate')
ylabel('True positive rate')
title('ROC Curve for Classification ')
Tbl = table(FPR, TPR, Thr)
%% FAR = FPR = FP/(FP + TN) and FRR = FNR = FN/(FN + TP)
fprintf('\n\n Overall accuracy:%f%%\n',cp.CorrectRate*100);
%% calculating elapsed time for execution
toc
10 件のコメント
dpb
2020 年 2 月 22 日
Don't have NN TB so can't run but the above code doesn't look like is a struct passed; you sure you're looking at the right code that generated the error?
Set a breakpoint and show us what
whos P_train
returns when breaks on entry to the subject line...
Walter Roberson
2020 年 2 月 22 日
We need the two .txt files to test with as well.
Check the result of load() of the .txt files: it is potentially returning a struct rather than numeric.
dpb
2020 年 2 月 22 日
That's so, Walter, but the posted code doesn't use the result of those text files to get to the line that shows the error...so is still a mystery.
Balaji M. Sontakke
2020 年 2 月 23 日
Balaji M. Sontakke
2020 年 2 月 23 日
dpb
2020 年 2 月 23 日
I can see how that solves a problem with respect to stats struct; I don't see how it really has anything to do with the original posting/code, though...
Walter Roberson
2020 年 2 月 23 日
The original db5.mat and db6.mat contain cell array of struct that are converted to array of struct and those are passed to mapminmax() . However, mapminmax() can only operate on numeric values. The problem was that the source data was in the wrong form.
It appears that the struct was being created by calling GLCM_feature_vec which was returning a struct. Feature vectors are never structs, though, they must always be numeric. The modified version of the code appears to extract the numeric parts acceptably.
dpb
2020 年 2 月 23 日
Huh. I'd forgotten cell2mat will return an array of an underlying type including a struct array...was thinking that would have had to have erred if result wasn't a "real" matrix.
Walter Roberson
2020 年 2 月 24 日
It depends on the release which datatypes are supported by cell2mat()
dpb
2020 年 2 月 24 日
Well, mayhaps hadn't forgotten but had never realized... :)
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!