フィルターのクリア

how to use soundsc with function

1 回表示 (過去 30 日間)
moonman
moonman 2011 年 10 月 6 日
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???

採用された回答

Wayne King
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.
  1 件のコメント
moonman
moonman 2011 年 10 月 7 日
Thanks a lot Wayne King
I have understood now

サインインしてコメントする。

その他の回答 (5 件)

Wayne King
Wayne King 2011 年 10 月 6 日
Is your dtmf a Nx1 cell array? Can you do
soundsc(cell2mat(dtmf),Fs)

moonman
moonman 2011 年 10 月 6 日
My dtmf is
1x38416 double
When i run ur command i get this error
>> soundsc(cell2mat(dtmf),fs) ??? Cell contents reference from a non-cell array object.
Error in ==> cell2mat at 43 cellclass = class(c{1});
But the book is asking very strange command
sound(dtmfdial([input]),12000)
Is it possible???

Wayne King
Wayne King 2011 年 10 月 6 日
Transpose your cell array
dtmf = dtmf';
Then try
soundsc(cell2mat(dtmf),8000);

moonman
moonman 2011 年 10 月 6 日
I think Wayne u r not getting the issue
this code is perfect and running fine
I am stuck to use this command
*The book says that following matlab command should play the tones corresponding to input vector,input,through computer speaker
sound(dtmfdial([input]),12000)*
Is it Possible

moonman
moonman 2011 年 10 月 6 日
Thanks Wayne King I did not check the command and assumed it will not work but it worked without any change
but can u kindly explain me how does it work
soundsc(dtmfdial([3 7 3]),8000)
what i understand the soundsc command calls dtmfdial function
but how tone is generated, the tone is actually in output cell array dtmf but we never told matlab to use that
Does matlab automatically pick the output of function???
  1 件のコメント
Walter Roberson
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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by