add a millisecond of silence to a sound?

7 views (last 30 days)
Oddineus
Oddineus on 15 Sep 2018
Reopened: madhan ravi on 4 Nov 2018
i do create a white noise sound and i want to add a milliseconds of silence moment to it. how to do that? and how to customize the location of the silence and the duration? this is the code:
% clc;clear all;close all;
sf = 44100;
d= input('total duration of stimulus (in sec) = ');
n = sf * d;
noise = randn(1, n);
noise = noise / max(abs(noise));
disp('WhiteNoise');
sound(noise, sf);
x = linspace(0, d, n);
plot(x,noise);
xlabel('time (s)');
title('sound: noise');
grid on;
thank you.

Answers (1)

Image Analyst
Image Analyst on 15 Sep 2018
Use zeros() to insert zero, something like
signal = [signal(1:index), ones(1, numSamples), signal(index+1:end)]
Vary index and numSamples, and variable names to achieve what you want.

Community Treasure Hunt

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

Start Hunting!