To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / utilities / temp.m @ 38:c2204b18f4a2

History | View | Annotate | Download (1.09 KB)

1 38:c2204b18f4a2 rmeddis
frequencies=[1000 1250];
2
amplitudesdB=[20 23];
3
nFrequencies=length(frequencies);
4
5
dt=0.0001;
6
7
toneDuration=.010;
8
time=dt:dt:toneDuration;
9
10
% fixed ramp, silenceDuration, toneDuration
11
rampDuration=0.005;
12
rampTime=dt:dt:rampDuration;
13
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
14
    ones(1,length(time)-length(rampTime))];
15
ramp=ramp.*fliplr(ramp);
16
17
silenceDuration=0.010;
18
silenceDurationLength=round(silenceDuration/dt);
19
initialSilence=zeros(1,silenceDurationLength);
20
21
silenceToneDuration=toneDuration + silenceDuration;
22
silenceToneDurationLength=round(silenceToneDuration/dt);
23
24
totalDuration=silenceToneDuration*nFrequencies;
25
totalDurationLength=round(totalDuration/dt);
26
stimulus=zeros(1,totalDurationLength);
27
toneBeginPTR=1;
28
29
for i=1:nFrequencies
30
    frequency=frequencies(i);
31
    dBSPL=amplitudesdB(i);
32
    amplitude=28e-6* 10.^(dBSPL/20);
33
    tone=amplitude*sin(2*pi*frequency*time);
34
    tone=tone.*ramp;
35
    stimulus(toneBeginPTR:toneBeginPTR+silenceToneDurationLength-1)=...
36
        [initialSilence tone];
37
    toneBeginPTR=toneBeginPTR+silenceToneDurationLength;
38
end
39
figure(2), plot( stimulus')