Plotting more than one DTMF frequencies on a graph

조회 수: 1 (최근 30일)
kyin gab
kyin gab 2012년 11월 25일
댓글: Yusra Banday 2023년 4월 26일
Hello,
I can plot single dtmf frequency. I would like to plot more than one frequency on a single graph. How do I do it?
Exampl below:
t = 0:1/32798:0.25-1/32798; x = sin(2*pi*xxx*t) + sin(2*pi*yyy*t);
x2 = sin(2*pi*aaa*t2) + sin(2*pi*bbb*t2);
if I do
plot(t, x); title('DTMF Signal for t = 0.25s'); xlabel('time (s)'); ylabel('Amplitude');
it will plot x for me.
Now I would like to plot x and x2 on the same graph. I am aware of putting frequency of zero in between.
Thank you.
  댓글 수: 2
Jonathan Epperl
Jonathan Epperl 2012년 11월 25일
It's not clear to me, what exactly you are asking. Are you asking how to put more than one line in a plot? If so, either
plot(t,x,'b',t2,x2,'k');
or
plot(t,x);
hold on
plot(t2,x2);
hold off
but please read the documentation
doc plot
kyin gab
kyin gab 2012년 11월 25일
I may not be clear enough.
I have two signal gotten from a keypad (number 2 and 7);
t = 0:1/32798:0.25-1/32798;
x2 = sin(2*pi*1336*t) + sin(2*pi*697*t);
x7 = sin(2*pi*1209*t) + sin(2*pi*852*t);
I want to plot these two signals in one graph. I am finding it difficult to do it. I want the graph to look like the last one on page 2 of this www.engr.mun.ca/~sircar/project1_files/dtmf.pdf
I am aware that I have to add a silence period between.
Thank you.

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

채택된 답변

Jonathan Epperl
Jonathan Epperl 2012년 11월 25일
Okay, now that your question is clearer to me, I think this is what you want:
t = 0:1/32798:0.25-1/32798;
x2 = sin(2*pi*1336*t) + sin(2*pi*697*t);
x7 = sin(2*pi*1209*t) + sin(2*pi*852*t);
int_of_silence = .1; shift = t(end)+ int_of_silence;
plot(t, x2, 'b', t+shift, x7, 'b', [t(end) t(end)+int_of_silence], [0 0], 'b', t+2*shift, x2, 'b', 2*[t(end) t(end)+int_of_silence], [0 0], 'b')
You see the trick is shifting the time axis for each segment by the right amount, I called it shift. The [t(end) t(end)+int_of_silence], [0 0], 'b' part is only to draw a line at 0 between segments.
  댓글 수: 3
JAFARU IBRAHIM
JAFARU IBRAHIM 2017년 11월 8일
Hi, Thank you very much (both of you),
I really found this question very important and related to my problem, so please Jonathan or Kyarn, how can you play the sound of the signal above, then? Tanx
Yusra Banday
Yusra Banday 2023년 4월 26일
now if we have to plot all the12 tones on a same graph.We can use subplot but graphs cant still be hold.so how can v get all graphs plotted on same fig??

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by