我希望产生10hz到1000hz的频率,步长为10hz,假设在5s内(所有频率在时间范围内均匀分布)。如何通过下面的单个频率发生器功能实现这一目标?
function [ ] = producefeq( frequency, duration, amplitude, freqsampling )
if ~exist('freqsampling', 'var'), freqsampling = 44100; end
if ~exist('amplitude', 'var'), amplitude = 1; end
if nargin <2, error('Not enough input arguments'); end
% the frequency argument will be like this for the case above 10:10:1000
t = 0:(1/freqsampling):duration;
y = amplitude*sin(2*pi*frequency*t);
sound(y, freqsampling);
end
提前致谢!
答案 0 :(得分:0)
您可以多次致电producefeq
并使用pause
在多次执行之间等待。
totalDuration = 500;
frequencies = 10:10:1000;
duration = totalDuration/length(frequencies);
for i = 1:length(frequencies)
producefeq( frequencies(i), duration)
pause(duration)
end