Function to play sequential tones with frequencies as input arguments
显示 更早的评论
I am new to MATLAB and trying to write a function that produces multiple tones and plays them through the soundcard sequentially, with an interstimulus interval (ISI) between each tone. For input arguments, I want the function to accept the frequency of tones to be played (so tones(500,1000,1500) would play 3 tones at the three respective frequencies).
I am new, so don't judge, but thus far I have:
sequence=[];
for k=1:length(nargin)
if nargin==0;disp('Error! Please enter at least one frequency.');
elseif nargin>0;freq=varargin{1:length(nargin)};end;
sr=44100;
dur=0.5; %tone duration is 0.5 sec
t=0:1/sr:dur;
y=sin(2*pi*freq*t);
isiDur=1.5; %ISI duration is 1sec+tone duration because they play simultaneously
isiT=0:1/sr:isiDur; %ISI will now play for 1sec after tone
isi=sin(0*isiT);
sequence=[sequence;y(:)];
end;
sound(sequence,sr)
If I play sound(y,sr) sound(isi) then I can get one tone and ISI. But, I can't get sequential tones regardless of the ISI aspect. Please help!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Direction of Arrival Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!