Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
if and and statemtn help
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone, I have a vector consisting of distance values between test vectors and reconstruction points. k is a vector that when the difference is found the minimum value corresponds to the reconstruction vector closest to it. This placement is kept in vector k. I want to do is find the distortion which is sum up all the differences in the clusters where the points are closest to a particular reconstruction level and then divide by how many points are in that cluster. so if k=1(if points are near the 1st reconstruction points) then get the corresponding difference found by distance and add that to all other points in the first reconstruction point k=1) . and if k==2(points are near the second cluster) take all those values near the R.P and add them up then divide by how many points correspond to that R.L. please help!! %% % Data Compression Project: Analyzing Vector Quantization with Greetings % in Different Languages
clear all;
close all;
% Test Signals were recorded using Sound Recorder app on My Samsung laptop.
% It was then transferred into MATLAB using the function wavread which defaults the
% sampling interval to 44,000 Hertz .
%Training Sets:
Test_Signal_1 = wavread('See ya later'); % "See ya later"
Test_Signal_2 = wavread('Nice to meet you'); % "Nice to meet you"
Test_Signal_3 = wavread('im fine'); % "I'm fine"
Test_Signal_4 = wavread('how are you');% "How are you"
Test_Signal_5 = wavread('Hello'); % "Hello"
Test_Signal_6 = wavread('Goodbye'); % "Goodbye"
Test_Signal_7 = wavread('good night'); % "Good night"
% We will use the Speech "See ya later" to create our vector quantizer
figure(1)
plot(Test_Signal_1(:,1));
% The imported Test signals are represented in MATLAB as 2 identical data
% columns. We discarded one column and used the first. Using Vector
% Quantization we will divided the signals into different clustered
% vectors and test their results. The creation of the vectors used for
% the quantization are obtained by using function reshape. We want
% consecutive data values in the vector clusters so this is how its done.
% Training Vectors from Training Set
TestVector_1 = reshape(Test_Signal_1(:,1),2,length(Test_Signal_1)/2)';
plot(TestVector_1(:,1),TestVector_1(:,2),'*')
% Determining Reconstruction Levels
M1 = 256; % 8 bits/vector
M2 = 512; % 9 bits/vector
M3 = 1024; % 10 bits/vector
M4 = 2048; % 11 bits/vector
M5 = 4096; % 12 bits/vector
Threshold = 1;
P = .01*randn(1); % Perturbation
RLs = zeros(256,2);
RL = .1*randn(size(RLs));
Distance_values = zeros(1,49152);
k = zeros(1,49152);
for i = 1:length(TestVector_1);
%Solve for Differences between Test Vectors and Reconstruction Levels
Difference = bsxfun(@minus,TestVector_1(i,:),RL)';
Distance = sqrt(sum(Difference.^2));
[Distance_values(:,i),k(:,i)] = min(Distance);
end
%Finding total Distortion
for j = 1:length(M1)
if
k=k';
Freq1 = histc(k,1:M1);
Freq = Freq1';
0 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!