Error using wavread on only a file?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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)
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
after i process.wav file (can't be read)
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
%
0 comentarios
Respuestas (1)
Jan
el 28 de Jun. de 2013
Editada: Jan
el 28 de Jun. de 2013
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);
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!