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!
Best Answer