how to use soundsc with function
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi i have written a code which is executing perfectly for DTMF tones with this command. I am listening tones in speaker
dtmf=dtmfdial([1 1 9 9 2 2 0 0]);
The last portion of my code is
dtmf = cat(2, D{:});
soundsc(dtmf,12000);
Now the book says that following matlab command should play the tones corresponding to input vector,input,through computer speaker
sound(dtmfdial([input]),12000)
How can i achieve this, what should i do with my final cell dtmf???
댓글 수: 0
채택된 답변
Wayne King
2011년 10월 6일
Your function is actually outputting a vector. Your code
dtmf = cat(2, D{:});
is producing a vector, soundsc() works on that vector. So the line
soundsc(dtmfdial([3 7 3]),8000)
Says "call dtmfdial with the input [3 7 3] which inside your code builds a signal (the vector dtmf) out of the frequencies defined by that input vector (in table). Play the output of dtmfdial() with a sampling frequency 8,000 Hz.
추가 답변 (5개)
Wayne King
2011년 10월 6일
Transpose your cell array
dtmf = dtmf';
Then try
soundsc(cell2mat(dtmf),8000);
댓글 수: 0
moonman
2011년 10월 6일
댓글 수: 1
Walter Roberson
2011년 10월 8일
When a function A is given as an argument to another function B, then the first output of A becomes an input to B. *Only* the first output of A is accessible when you do this: there is NO way in MATLAB to have multiple outputs of a function used as inputs to another function, other than assigning those multiple outputs to variables and passing in the variables.
참고 항목
카테고리
Help Center 및 File Exchange에서 DTMF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!