My task is to load a signal, then take every 8th sample and compare it with 0.
If sample > 0 -> sample=1 else sample -> 0.
I have a code like this:
sn = wavread('example.wav',100);
z = sn(1 : 1 : end);
x = sn(1 : 1 : end);
for i = 1:rows(z);
for j = 1:columns(z);
if(z(i,j) < 0);
z(i,j) = 0;
else
z(i,j) = 1;
endif
endfor
endfor
plot(x, "*",z, "o");
My problem is that if i select every 8th sample like this:
z = sn(1 : 8 : end);
It keep only every 8th sample and result is this:
What i need is to keep my 100 samples and print only every 8th so it keeps scale of first picture.
Thank's for any advice.
EDIT: I used
idx = 1:8:numel(z);
z(idx) = z(idx) > 0;
and now it looks like this:
Is there any way to print out only samples that has value 1 or 0 and force them to stay on it's original indexes? For example on indexes 1,9,17,25,33 is val 1 or 0. I want them to stay on those indexes and ingnore others when i call plot(z) .