Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- close
- clear
- X = audioread('ATrain.wav');
- X = double(X);
- X = floor(X * 2^15 + 0.5);
- L1 = X(:,1);
- P1 = X(:,2);
- [x,y] = size(X);
- L = zeros(x,1);
- P = zeros(x,1);
- L(1) = L1(1);
- P(1) = P1(1);
- DL = zeros(2*(2^16)-1,1);
- DP = zeros(2*(2^16)-1,1);
- [x1,y2] = size(DL);
- for i= 2:x
- L(i) = L1(i) - L1(i-1);
- P(i) = P1(i) - P1(i-1);
- end
- for i = 1:x
- if L(i) < 0
- DL(L(i) + 65536 ) = DL(L(i) + 65536 ) + 1;
- else
- DL(L(i) + 65536 ) = DL(L(i) + 65536 ) + 1;
- end
- if P(i) < 0
- DP(P(i) + 65536 ) = DP(P(i) + 65536 ) + 1;
- else
- DP(P(i) + 65536 ) = DP(P(i) + 65536 ) + 1;
- end
- end
- PL = DL/x;
- PP = DP/x;
- SL = 0;
- SP = 0;
- for i = 1:x1
- if PL(i) ~= 0
- SL = SL + (PL(i) .* log2(PL(i)));
- end
- if PP(i) ~= 0
- SP = SP + (PP(i) .* log2(PP(i)));
- end
- end
- l = -SL;
- p = -SP;
- fprintf('Entropia lewego kanału po kodowaniu: %f\n', l)
- fprintf('Entropia prawego kanału po kodowaniu: %f\n', p)
- fprintf('Srednia arytmetyczna lewego i prawego kanalu: %f\n', (p+l)/2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement