Clear Filters
Clear Filters

How to solve the code?

3 views (last 30 days)
Darsana P M
Darsana P M on 25 Jul 2017
Commented: Darsana P M on 27 Jul 2017
Can somebody help me out.I am preforming the cocktail problem ie I have two signals, I deliberately mix them and I have to recover both the signals separately.In the code below, the two signals are shown as red and blue.I was able to separate the first signal. I need to extract the other signal also. How will I do it?
f1 = 1100; % frequency of tone generator 1; unit: Hz
f2 = 2900; % frequency of tone generator 2; unit: Hz
Ts = 1/(40*max(f1,f2)); % sampling period; unit: s
dMic = 1; % distance between microphones centered about origin; unit: m
dSrc = 10; % distance between tone generators centered about origin; unit: m
c = 340.29; % speed of sound; unit: m / s
% generate tones
figure(1);
t = [0:Ts:0.025];
tone1 = sin(2*pi*f1*t);
tone2 = sin(2*pi*f2*t);
plot(t,tone1);
hold on;
plot(t,tone2,'r'); xlabel('time'); ylabel('amplitude');
axis([0 0.005 -1 1]); legend('tone 1', 'tone 2');
hold off;
dMic=0
% mix tones at microphones
% assume inverse square attenuation of sound intensity (i.e., inverse linear attenuation of sound amplitude)
figure(2);
dNear = (dSrc - dMic)/2;
dFar = (dSrc + dMic)/2;
mic1 = 1/dNear*sin(2*pi*f1*(t-dNear/c)) + 1/dFar*sin(2*pi*f2*(t-dFar/c));
mic2 = 1/dNear*sin(2*pi*f2*(t-dNear/c)) + 1/dFar*sin(2*pi*f1*(t-dFar/c));
plot(t,mic1);
hold on;
plot(t,mic2,'r'); xlabel('time'); ylabel('amplitude');
axis([0 0.005 -1 1]); legend('mic 1', 'mic 2');
hold off;
% use svd to isolate sound sources
figure(3);
x = [mic1' mic2'];
[W,s,v]=svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x');
plot(t,v(:,1));
hold on;
maxAmp = max(v(:,1));
plot(t,v(:,2),'r'); xlabel('time'); ylabel('amplitude');
axis([0 0.005 -maxAmp maxAmp]); legend('isolated tone 1', 'isolated tone 2');
hold off;

Accepted Answer

David Goodmanson
David Goodmanson on 25 Jul 2017
Edited: David Goodmanson on 25 Jul 2017
Hi Darsana,
I don't know how close the answer is supposed to be to tones with unit amplitude, but if you get rid of the odd dMic=0 command halfway down the code, the results look a lot better. With dMic=0 the two microphone signals are identical and svd has a pretty hard task.
  3 Comments
David Goodmanson
David Goodmanson on 26 Jul 2017
do you mean
figure(1)
plot(t,v(:,1))
xlabel('time') % etc.
figure(2)
plot(t,v(:,2))
xlabel('time') % etc.
Darsana P M
Darsana P M on 27 Jul 2017
Thanks a lot.

Sign in to comment.

More Answers (0)

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!