Error using wavread on only a file?

조회 수: 1 (최근 30일)
I Made
I Made 2013년 6월 28일
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)
%

답변 (1개)

Jan
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);
  댓글 수: 1
I Made
I Made 2013년 6월 28일
i'm very sorry i write the code wrong.. i'm already edit it..
First time i use to write my code like you.. But same result it's not working for this 1 file.. Another file works just fine

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by