Attempted to access key(2,0); index must be a positive integer or logical.
Show older comments
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 ~
Answers (1)
Image Analyst
on 13 Feb 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 Comments
MU
on 14 Feb 2013
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!