Attempted to access key(2,0); index must be a positive integer or logical.
Afficher commentaires plus anciens
Hello, everyone, i was stuck in one source code line, and i really do not understand how to fix it. here is the source code
[y fs] = wavread('random.wav');
plot(y);
tsamp = 0.01;
t = linspace(0,tsamp,tsamp*fs+1);
M = length(t);
N = floor(length(y)/M);
ys = reshape(y(1:(N*M)),M,N);
fL = [697 770 852 941];
fH = [1209 1336 1477 1633];
omega = 2*pi*fL';
w = exp(1j*omega*t);
yL = abs(w*ys)/M;
plot(yL');
omega = 2*pi*fH';
w = exp(1j*omega*t);
yH = abs(w*ys)/M;
plot(yH');
ndx = 1:4; y1 = ndx*(yL>0.07);
subplot(2,1,1);
plot(y1);
ylabel('low freq index');
subplot(2,1,2);
y2 = ndx*(yH>0.07);
plot(y2);
ylabel('high freq index');
ndx = find(diff(y1)>0);
n1 = y1(ndx+2);
n2 = y2(ndx+2);
[n1' n2']
key = ['147*'; '2580'; '369#'; 'ABCD'];
for k=1:length(n1) pn(k) =key(n2(k),n1(k));
end
disp('phone number:');
disp(pn);
the system says the error is "Attempted to access key(2,0); index must be a positive integer or logical."||
Thanks ~
Réponses (1)
Image Analyst
le 13 Fév 2013
0 votes
Your second index to the key array is zero. That's not allowed. I don't know WHY it is zero - we'll let you figure that out, which you can easily do if you know how to use the debugger.
2 commentaires
MU
le 14 Fév 2013
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!