Why am I getting unrecognized function or variable 'length' ??
Show older comments
Hi!! I am building a code to create a convolutional neural network but for some reason when I call the function used to train the CNN it always raises an error "Unrecognized function or variable 'length'" at the same point.
I don't understand why this happens since "length" in an intrinsic matlab function and its working well on other functions/scripts...
[Ptrain,Ttrain,Trg_train,Ptest,~,Trg_test]=building_trainset_testset(features,new_Trg,T,ind_seizureBeginning); rng(0);
[Ptrain,Trg_train,~]=class_balancing(Trg_train,Ttrain,Ptrain); Ptrain=mat2gray(Ptrain);
%Building 4D matrix (29 (instants)x29 (features) x1 (because images are grey) x numberofImages)
newPtrain=[]; newTrg_train=[]; window_width=29; count=0;
ind_inter=find(Trg_train==1);
ind_preictal=find(Trg_train==2);
ind_ictal=find(Trg_train==3);
ind_posictal= find(Trg_train==4);
% THIS IS WHERE THE ERROR RAISES
for i=1:length(ind_inter)
if i<length(ind_inter)-28
count=count+1;
newPtrain(:,:,1,count)=Ptrain(:,ind_inter(i:i+28));
newTrg_train=[newTrg_train; 1];
end
end
% REST OF THE CODE
newTrg_train=categorical(int64(newTrg_train));
1 Comment
Torsten
on 6 Nov 2022
Maybe somewhere in your code you used the name "length" for a variable ?
Try
clear length
at the beginning of the function. Does the error message pertain ?
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!