Error using wavread on only a file?
3 次查看(过去 30 天)
显示 更早的评论
So here is my code & problem:
ButtonA
function pushbutton5_Callback(hObject, eventdata, handles)
[fileName,filePath]=uigetfile({'.wav'},'File Selector');
name = fullfile(filePath,fileName);
handles.fileName=name;
guidata(hObject,handles);
Button B
function pushbutton8_Callback(hObject, eventdata, handles)
File=handles.fileName;
[data, Fs, nbits] = wavread(File);
The error : only errror if i input a processed file. other files are fine
??? Error using ==> wavread at 166 Invalid field name: ''.
Error in ==> attack>pushbutton8_Callback at 338 [data, Fs, nbits] = wavread(File);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> attack at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)attack('pushbutton8_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
What is strange here is this code is work for all my file except 1, which is a file that i've been doing some process in it actually it is watermarking. So what i wanted to know is why is this happening ? what specification for a file can be read using wavread?
And 1 thing come on my mind that the only different that the error file than the other have was before the data header.. take a look at this pict, could it be the problem?
before i process .wav file (can be read)
after i process.wav file (can't be read)
%
0 个评论
回答(1 个)
Jan
2013-6-28
编辑:Jan
2013-6-28
You do not define the variable File at all in:
function pushbutton8_Callback(hObject, eventdata, handles)
[data, Fs, nbits] = wavread(File);
Therefore I'm surprised about the error message. Actually File should be undefined and not the empty string.
This callback has to obtain the file name from where it is stored:
function pushbutton8_Callback(hObject, eventdata, handles)
handles = guidata(hObject); % Is this required to get the newest version?
[data, Fs, nbits] = wavread(handles.fileName);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!