Choose frequency to plot and create sound
이전 댓글 표시
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).
답변 (1개)
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)
.
카테고리
도움말 센터 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




