Index exceeds matrix dimension for the statement : rMatrix = cell2mat(cell_rMatrix(1,i));
Info
This question is closed. Reopen it to edit or answer.
Show older comments
function pb_extractMatching_Callback(hObject, eventdata, handles)
% hObject handle to pb_extractMatching (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% -------------------------
% proses feature extracting
% -------------------------
global signal;
global scores;global C;
% global SM;
global p1;global p2;global p3;global p4;global p5;global p6;
global q1;global q2;global q3;global q4;global q5;global q6;
ncoeff = 13; %Required number of mfcc coefficients
fs=5*8000; %Sampling rate
G=2;
%wavplay(signal,5*8000)
signal2 = signal.*G;
signal3 = signal2 - mean(signal2); %DC offset elimination
speechIn = nreduce(signal3,fs); %Applies spectral subtraction
fMatrix1 = mfccf(ncoeff,speechIn,fs); %Compute test feature vector
fMatrix = CMN(fMatrix1); %Removes convolutional noise
pjg_cellMatrix = length(fMatrix);
% -------------------------
% proses feature matching
% -------------------------
scores = zeros(1,10);
databaseReference = get(handles.edit_selectDatabase,'String')
load (databaseReference, 'cell_rMatrix','cell_vectorname');
for i=1:10
rMatrix = cell2mat(cell_rMatrix(1,i));
rMatrix = CMN(rMatrix);
pjg_cellMatrix2 = length(rMatrix);
[p,q,hasil]= myDTW(rMatrix,fMatrix);
scores(i)=hasil;
if(i==1)
p1=p;
q1=q;
elseif(i==2)
p2=p;
q2=q;
elseif(i==3)
p3=p;
q3=q;
elseif(i==4)
p4=p;
q4=q;
elseif(i==5)
p5=p;
q5=q;
elseif (i==6)
p6=p;
q6=q;
elseif (i==7)
p7=p;
q7=q;
elseif (i==8)
p8=p;
q8=q;
elseif (i==9)
p9=p;
q9=q;
else
p10=p;
q10=q;
end
end
[NilaiMin indexMin]= min(scores)
if (NilaiMin < 50000)
set(handles.edit_HASIL,'String', strcat('The spoken file is : ',cell2mat(cell_vectorname(1,indexMin))));
C=cell2mat(cell_vectorname(1,indexMin));
else
set(handles.edit_HASIL,'String', 'File not found');
end
msgbox('Extraction and Matching Finished !!!','info process')
% --- Executes on button press in pb_outputDetail.
function pb_outputDetail_Callback(hObject, eventdata, handles)
% hObject handle to pb_outputDetail (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
detailDTW
function pb_playback_Callback(hObject, eventdata, handles)
global C;
D=strcat(C,'.wav');
D = wavread(D);
D = 0.99*D/max(abs(D));
wavplay(D,5*8000);
function plot_sig()
global signal
samp_len = length(signal)/5*8000;
delta_t = 1/5*8000;
t = 0:delta_t:(samp_len-delta_t);
% display the signal
plot(t,signal)%, xlabel('Time [sec]'), ylabel('Amplitude')
axis([0 t(length(signal)-1) -1 1 ]);
2 Comments
Walter Roberson
on 29 Jan 2013
Instead of global p1, p2, p3, and so on, and the if/elseif chain, why not just global Pvals and set Pvals{i} = p; ?
Note: This:
s = cell_vectorname{1,indexMin}
is nicer and faster than:
s = cell2mat(cell_vectorname(1,indexMin))
Instead of using p1, p2, ...p10, a vector p(1:10) would be more efficient and easier to handle.
Answers (1)
Walter Roberson
on 29 Jan 2013
You have not given us any reason to expect that cell_rMatrix is a row vector containing at least 10 elements. It might be a column vector instead, or it might have fewer elements. After you do the load() operation, you should display
size(cell_rMatrix)
to see what size it really is.
4 Comments
Walter Roberson
on 30 Jan 2013
So it is 1 x 4, but you have "for i=1:10" so you are going to try to access up to 1 x 10 and that will fail as soon as "i" hits 5.
Perhaps you should be coding
for i = 1 : length(cell_rMatrix)
anju
on 30 Jan 2013
anju
on 30 Jan 2013
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!