Mercurial > hg > map
view testPrograms/html/myConv.html @ 19:5b23b9f11806
MAP debugging
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Tue, 07 Jun 2011 17:50:05 +0100 |
parents | 35af36fe0a35 |
children |
line wrap: on
line source
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> <html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- This HTML is auto-generated from an M-file. To make changes, update the M-file and republish this document. --> <title>myConv</title> <meta name="generator" content="MATLAB 7.6"> <meta name="date" content="2011-06-05"> <meta name="m-file" content="myConv"><style> body { background-color: white; margin:10px; } h1 { color: #990000; font-size: x-large; } h2 { color: #990000; font-size: medium; } /* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. */ p,h1,h2,div.content div { max-width: 600px; /* Hack for IE6 */ width: auto !important; width: 600px; } pre.codeinput { background: #EEEEEE; padding: 10px; } @media print { pre.codeinput {word-wrap:break-word; width:100%;} } span.keyword {color: #0000FF} span.comment {color: #228B22} span.string {color: #A020F0} span.untermstring {color: #B20000} span.syscmd {color: #B28C00} pre.codeoutput { color: #666666; padding: 10px; } pre.error { color: red; } p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray; } </style></head> <body> <div class="content"> <h2>Contents</h2> <div> <ul> <li><a href="#3">testing convolution speculation</a></li> <li><a href="#4">convolution function</a></li> <li><a href="#5">normalise conv function</a></li> <li><a href="#6">adjust for spike current</a></li> <li><a href="#7">convolution</a></li> </ul> </div><pre class="codeinput">signalDuration=.1; spikeTime= signalDuration/2; <span class="keyword">for</span> sampleRate=[1000 2000]; </pre><pre class="codeinput"> disp([<span class="string">'sample rate= '</span> num2str(sampleRate)]) </pre><pre class="codeoutput">sample rate= 1000 </pre><pre class="codeoutput">sample rate= 2000 </pre><h2>testing convolution speculation<a name="3"></a></h2><pre class="codeinput">dt= 1/sampleRate; signalLength=round(signalDuration/dt); spikeArray=zeros(1,signalLength); spikeLocation=round(spikeTime/dt); spikeArray(spikeLocation)=1; disp([<span class="string">'length of spike array= '</span> num2str(length(spikeArray))]) t=dt*(1:length(spikeArray)); plot(t, spikeArray) </pre><pre class="codeoutput">length of spike array= 100 </pre><img vspace="5" hspace="5" src="myConv_01.png"> <pre class="codeoutput">length of spike array= 200 </pre><img vspace="5" hspace="5" src="myConv_06.png"> <h2>convolution function<a name="4"></a></h2><pre class="codeinput">CNspikeToCurrentTau=0.01; t=dt:dt:3*CNspikeToCurrentTau; CNalphaFunction=<span class="keyword">...</span> (1/CNspikeToCurrentTau)*t.*exp(-t/CNspikeToCurrentTau); plot(t, CNalphaFunction) </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); plot(t, CNalphaFunction) disp([<span class="string">'area under function= '</span> num2str(sum(CNalphaFunction))]) </pre><pre class="codeoutput">area under function= 1 </pre><img vspace="5" hspace="5" src="myConv_03.png"> <pre class="codeoutput">area under function= 1 </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; CNalphaFunction=CNalphaFunction*CNcurrentPerSpike; plot(t, CNalphaFunction) </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); t=dt*(1:length(result)); plot(t, result) disp([<span class="string">'area under function= '</span> num2str(sum(result))]) </pre><pre class="codeoutput">area under function= 2 </pre><img vspace="5" hspace="5" src="myConv_05.png"> <pre class="codeoutput">area under function= 2 </pre><img vspace="5" hspace="5" src="myConv_10.png"> <pre class="codeinput"><span class="keyword">end</span> </pre><p class="footer"><br> Published with MATLAB® 7.6<br></p> </div> <!-- ##### SOURCE BEGIN ##### signalDuration=.1; spikeTime= signalDuration/2; for sampleRate=[1000 2000]; disp(['sample rate= ' num2str(sampleRate)]) %% testing convolution speculation dt= 1/sampleRate; signalLength=round(signalDuration/dt); spikeArray=zeros(1,signalLength); spikeLocation=round(spikeTime/dt); spikeArray(spikeLocation)=1; disp(['length of spike array= ' num2str(length(spikeArray))]) t=dt*(1:length(spikeArray)); plot(t, spikeArray) %% convolution function CNspikeToCurrentTau=0.01; t=dt:dt:3*CNspikeToCurrentTau; CNalphaFunction=... (1/CNspikeToCurrentTau)*t.*exp(-t/CNspikeToCurrentTau); plot(t, CNalphaFunction) %% normalise conv function CNalphaFunction=CNalphaFunction/sum(CNalphaFunction); plot(t, CNalphaFunction) disp(['area under function= ' num2str(sum(CNalphaFunction))]) %% adjust for spike current CNcurrentPerSpike=2; CNalphaFunction=CNalphaFunction*CNcurrentPerSpike; plot(t, CNalphaFunction) %% convolution result=conv(spikeArray,CNalphaFunction); t=dt*(1:length(result)); plot(t, result) disp(['area under function= ' num2str(sum(result))]) end ##### SOURCE END ##### --> </body> </html>