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 / testPrograms / html / myConv.html @ 15:35af36fe0a35

History | View | Annotate | Download (5.45 KB)

1

    
2
<!DOCTYPE html
3
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
4
<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">
5
   <head>
6
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
   
8
      <!--
9
This HTML is auto-generated from an M-file.
10
To make changes, update the M-file and republish this document.
11
      -->
12
      <title>myConv</title>
13
      <meta name="generator" content="MATLAB 7.6">
14
      <meta name="date" content="2011-06-05">
15
      <meta name="m-file" content="myConv"><style>
16

17
body {
18
  background-color: white;
19
  margin:10px;
20
}
21

22
h1 {
23
  color: #990000; 
24
  font-size: x-large;
25
}
26

27
h2 {
28
  color: #990000;
29
  font-size: medium;
30
}
31

32
/* Make the text shrink to fit narrow windows, but not stretch too far in 
33
wide windows. */ 
34
p,h1,h2,div.content div {
35
  max-width: 600px;
36
  /* Hack for IE6 */
37
  width: auto !important; width: 600px;
38
}
39

40
pre.codeinput {
41
  background: #EEEEEE;
42
  padding: 10px;
43
}
44
@media print {
45
  pre.codeinput {word-wrap:break-word; width:100%;}
46
} 
47

48
span.keyword {color: #0000FF}
49
span.comment {color: #228B22}
50
span.string {color: #A020F0}
51
span.untermstring {color: #B20000}
52
span.syscmd {color: #B28C00}
53

54
pre.codeoutput {
55
  color: #666666;
56
  padding: 10px;
57
}
58

59
pre.error {
60
  color: red;
61
}
62

63
p.footer {
64
  text-align: right;
65
  font-size: xx-small;
66
  font-weight: lighter;
67
  font-style: italic;
68
  color: gray;
69
}
70

    
71
  </style></head>
72
   <body>
73
      <div class="content">
74
         <h2>Contents</h2>
75
         <div>
76
            <ul>
77
               <li><a href="#3">testing convolution speculation</a></li>
78
               <li><a href="#4">convolution function</a></li>
79
               <li><a href="#5">normalise conv function</a></li>
80
               <li><a href="#6">adjust for spike current</a></li>
81
               <li><a href="#7">convolution</a></li>
82
            </ul>
83
         </div><pre class="codeinput">signalDuration=.1;
84
spikeTime= signalDuration/2;
85
<span class="keyword">for</span> sampleRate=[1000 2000];
86
</pre><pre class="codeinput">    disp([<span class="string">'sample rate= '</span> num2str(sampleRate)])
87
</pre><pre class="codeoutput">sample rate= 1000
88
</pre><pre class="codeoutput">sample rate= 2000
89
</pre><h2>testing convolution speculation<a name="3"></a></h2><pre class="codeinput">dt= 1/sampleRate;
90
signalLength=round(signalDuration/dt);
91
spikeArray=zeros(1,signalLength);
92
spikeLocation=round(spikeTime/dt);
93
spikeArray(spikeLocation)=1;
94
disp([<span class="string">'length of spike array= '</span> num2str(length(spikeArray))])
95
t=dt*(1:length(spikeArray));
96
plot(t, spikeArray)
97
</pre><pre class="codeoutput">length of spike array= 100
98
</pre><img vspace="5" hspace="5" src="myConv_01.png"> <pre class="codeoutput">length of spike array= 200
99
</pre><img vspace="5" hspace="5" src="myConv_06.png"> <h2>convolution function<a name="4"></a></h2><pre class="codeinput">CNspikeToCurrentTau=0.01;
100
t=dt:dt:3*CNspikeToCurrentTau;
101
CNalphaFunction=<span class="keyword">...</span>
102
    (1/CNspikeToCurrentTau)*t.*exp(-t/CNspikeToCurrentTau);
103

    
104
plot(t, CNalphaFunction)
105
</pre><img vspace="5" hspace="5" src="myConv_02.png"> <img vspace="5" hspace="5" src="myConv_07.png"> <h2>normalise conv function<a name="5"></a></h2><pre class="codeinput">CNalphaFunction=CNalphaFunction/sum(CNalphaFunction);
106
plot(t, CNalphaFunction)
107
disp([<span class="string">'area under function= '</span> num2str(sum(CNalphaFunction))])
108
</pre><pre class="codeoutput">area under function= 1
109
</pre><img vspace="5" hspace="5" src="myConv_03.png"> <pre class="codeoutput">area under function= 1
110
</pre><img vspace="5" hspace="5" src="myConv_08.png"> <h2>adjust for spike current<a name="6"></a></h2><pre class="codeinput">CNcurrentPerSpike=2;
111
CNalphaFunction=CNalphaFunction*CNcurrentPerSpike;
112
plot(t, CNalphaFunction)
113
</pre><img vspace="5" hspace="5" src="myConv_04.png"> <img vspace="5" hspace="5" src="myConv_09.png"> <h2>convolution<a name="7"></a></h2><pre class="codeinput">result=conv(spikeArray,CNalphaFunction);
114
t=dt*(1:length(result));
115
plot(t, result)
116
disp([<span class="string">'area under function= '</span> num2str(sum(result))])
117
</pre><pre class="codeoutput">area under function= 2
118
</pre><img vspace="5" hspace="5" src="myConv_05.png"> <pre class="codeoutput">area under function= 2
119
</pre><img vspace="5" hspace="5" src="myConv_10.png"> <pre class="codeinput"><span class="keyword">end</span>
120
</pre><p class="footer"><br>
121
            Published with MATLAB&reg; 7.6<br></p>
122
      </div>
123
      <!--
124
##### SOURCE BEGIN #####
125
signalDuration=.1;
126
spikeTime= signalDuration/2;
127
for sampleRate=[1000 2000];
128
    disp(['sample rate= ' num2str(sampleRate)])
129

130
%% testing convolution speculation
131
dt= 1/sampleRate;
132
signalLength=round(signalDuration/dt);
133
spikeArray=zeros(1,signalLength);
134
spikeLocation=round(spikeTime/dt);
135
spikeArray(spikeLocation)=1;
136
disp(['length of spike array= ' num2str(length(spikeArray))])
137
t=dt*(1:length(spikeArray));
138
plot(t, spikeArray)
139

140
%% convolution function
141
CNspikeToCurrentTau=0.01;
142
t=dt:dt:3*CNspikeToCurrentTau;
143
CNalphaFunction=...
144
    (1/CNspikeToCurrentTau)*t.*exp(-t/CNspikeToCurrentTau);
145

146
plot(t, CNalphaFunction)
147

148
%% normalise conv function
149
CNalphaFunction=CNalphaFunction/sum(CNalphaFunction);
150
plot(t, CNalphaFunction)
151
disp(['area under function= ' num2str(sum(CNalphaFunction))])
152

153
%% adjust for spike current
154
CNcurrentPerSpike=2;
155
CNalphaFunction=CNalphaFunction*CNcurrentPerSpike;
156
plot(t, CNalphaFunction)
157

158
%% convolution
159
result=conv(spikeArray,CNalphaFunction);
160
t=dt*(1:length(result));
161
plot(t, result)
162
disp(['area under function= ' num2str(sum(result))])
163

164
end
165

166

167

168

169
##### SOURCE END #####
170
-->
171
   </body>
172
</html>