Choose frequency to plot and create sound
Afficher commentaires plus anciens
I have the variable k, which is equal to n*pi (n = 1,2,3,4,5,6). Is there any way to have all the values of k and choose every time one of them to plot and create sound of sin(k).
Réponses (1)
Star Strider
le 24 Fév 2023
Modifié(e) : Star Strider
le 24 Fév 2023
These frequencies are going to be too low to hear, so consider multiplying them by perhaps 100 in the sound call.
Fs = 44100; % Sampling Frequency (Hz)
Tlen = 10; % Signal Length (sec)
t = linspace(0, Tlen*Fs, Tlen*Fs+1)/Fs;
freq = pi*(1:6);
for k = 1:numel(freq)
chooseFreq = randi(numel(freq))
sv(:,k) = sin(t*freq(chooseFreq)).';
% sound(sv(:,k),Fs)
% pause(Tlen)
figure
plot(t, sv(:,k))
xlim([0 5])
title(sprintf('Frequency = %.2f',freq(chooseFreq)))
end
EDIT — (24 Feb 2023 at 23:34)
.
Catégories
En savoir plus sur Audio and Video Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




