How to solve the code?

조회 수: 2 (최근 30일)
Darsana P M
Darsana P M 2017년 7월 25일
댓글: Darsana P M 2017년 7월 27일
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;

채택된 답변

David Goodmanson
David Goodmanson 2017년 7월 25일
편집: David Goodmanson 2017년 7월 25일
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
David Goodmanson
David Goodmanson 2017년 7월 26일
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 2017년 7월 27일
Thanks a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by