フィルターのクリア

Create a signal from concatenating signals with pauses inbetween.

11 ビュー (過去 30 日間)
JustAnotherGuy
JustAnotherGuy 2018 年 5 月 22 日
回答済み: Aditya Salveru 2018 年 5 月 23 日
Greetings! I'm trying to create use sound on a signal creating by a random number of signals which should have pauses in between. The signals all have the same size so I was able to do it like this:
if true
Y = 0;
for ()
sig = x();
sigY = Y;
Y = [sig sigY];
end
end
Then I tried adding a signal with 0 value that lasts for as long as I want (pauses aren't fixed length) and concatenated this also like:
if true
Y = 0;
for ()
sig = x();
pauseSig = z();
sigY = Y;
Y = [sig pauseSig sigY];
end
end
However when I run this there's no pause. I think that sound() skips the 0 value signal completely, instead of being "paused" for that duration. Am I doing something wrong, or is there another way to do this? Thanks a lot!

回答 (1 件)

Aditya Salveru
Aditya Salveru 2018 年 5 月 23 日
Hi,
You can concatenate the signals with zeros of desired length to get a pause in the sound.
I have taken a sounds of three frequencies i.e 100,200,500 Hz and concatenated them along with a pause for a second. This actually works as intended.
You can find the code for the same below
fs=2000; %sampling rate.
t=0:1/fs:2-1/fs; %time values.
x1=2*sin(2*pi*100*t); %first sound.
x2=2*sin(2*pi*200*t); %second sound.
x3=2*sin(2*pi*500*t); %third sound.
pause=zeros(1,1*(fs)); %pause of length 2 seconds.
y=[x1 pause x2 pause x3]; %concatenation of sounds along with pause.
sound(y,fs); %playing the sound.
Hope this helps.
Thanks ,
Aditya.

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by