Undefined function or variable 'samples'.

3 views (last 30 days)
Deepu S S
Deepu S S on 21 Oct 2021
Commented: KSSV on 21 Oct 2021
function load_EEG(hObject, eventdata, handles)
% Function to load EEG file by browsing
% set(handles.RegionPanel, 'Visible','off');
% set(handles.LabelPanel,'Visible','off');
handles.FeatureMat=[];
handles.epil_ind=0;
handles.EEGLoadType='Total';% Loading the Data as a Total file
%% Added to check whether file loading done from UI or result viewer
if(handles.loadfilepassingFlag==0)
[filename,pathname] = uigetfile({'*.dat';'*.eeg';'*.txt';'*.ASC';'*.wav';'*.mp3'},'Select data File');
else
[pathname,fileName,ext]=fileparts(handles.loadingfile)
filename=strcat(fileName,ext)
end
if isequal(filename,0)
disp('No file selected')
else
% set(handles.Name_EEGFile,'string','Wait Loading File.......');
disp(['You have selected ', fullfile(pathname, filename)])
disp(['CHD processing' ,fullfile(pathname,filename)])
handles.fileName = filename;
[pathstr,name,ext] = fileparts(filename)
hh=handles.fileName
set(handles.Name_EEGFile,'String',handles.fileName);
%%%%%%%
if(strcmp(ext,'.data'))
Datadetails=readFreibergNewData( fullfile(pathname, filename) );
% Datadetails.sampRate
% Datadetails.channels
% Datadetails.montage
% Datadetails.duration
handles.eegData = Datadetails.data;
handles.Montage= Datadetails.montage;
handles.totalChannels=size(handles.eegData,2);
handles.samplingRate=Datadetails.sampRate;
% prompt = {'Enter Sampling Rate:','Enter number of Channels:','No: of seconds in a frame'};
% dlg_title = 'EEG Parameters---------------------------------------------------------';
% num_lines = 1;
% def = {handles.samplingRate,handles.totalChannels,'4'};
% options.Resize='on';
% options.WindowStyle='normal';
% options.Interpreter='tex';
% answer = inputdlg(prompt,dlg_title,num_lines,def);
guidata(hObject, handles);
elseif(strcmp(ext,'.mp3')||strcmp(ext,'.wav'))
% handles.filepath=fullfile(pathname,filename);
% [filepath, pathname] = uigetfile('*.wav');
%
% handles.filepath=fullfile(pathname,filepath);
%
% [y,Fs] = audioread( handles.filepath);
%
% handles.Audiodata=y;
%
% handles.Samplingrate=Fs;
% l=size(y)
% handles.Samplingrate=Fs;
% %
% % handles.eegData = y;
% % data=handles.eegData
% % handles.totalChannels=size(handles.eegData,2);
% % handles.samplingRate=Fs;
% % toCh=handles.totalChannels
% Read an audio waveform
% [filepath, pathname] = uigetfile('*.wav');
% [ y , Fs ] = audioread( filename ) ;
[y , Fs ] = audioread( filename , samples ) ;
% [y,Fs] = audioread( handles.filepath);
handles.audiodata = y;
handles.samplingrats = Fs;
else
handles.audioread ='';
handles.eegData = audioread (fullfile(pathname, filename));
handles.totalChannels=size(handles.eegData,2);
% else
%%Loading Montage file for SCT data...asha
t=tokenizeString(filename,'_.');
all_Bnifiles= dir('SCT_Montage');
all_BnifileNames= {all_Bnifiles.name}
curr_bni=strcat(t{end-1},'.txt')
if ismember(cellstr(curr_bni) ,all_BnifileNames)
disp('Found BNI')
montage=char(importdata(strcat('SCT_Montage\',curr_bni)))
h=tokenizeString(montage,',');
mtok=[];
for i=1:length(h)
% hhh=mtok{i}
mtok=[mtok cellstr(h{i})];
end
handles.Montage = mtok ;
else
disp('BNI NOT FOUND')
end
end
%%%%%%%%
when i excute aove code an error showing like
Undefined function or variable 'samples'.
Error in EEG_SCT>load_EEG (line 321)
[y , Fs ] = audioread( filename , samples ) ;
Error in EEG_SCT>Open_EEGFile_Callback (line 208)
load_EEG(hObject, eventdata, handles);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in EEG_SCT (line 37)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)EEG_SCT('Open_EEGFile_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating Menu Callback.
  1 Comment
KSSV
KSSV on 21 Oct 2021
variable samples is being used inside the function without providing it as a input.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by