Re: biologist new to matlab
- From: "NZTideMan" <mulgor@xxxxxxxxx>
- Date: 14 Apr 2007 21:59:58 -0700
On Apr 15, 2:27 pm, abeye...@xxxxxxxxx wrote:
Hi,
I'm a neurobiologist new to matlab (and programming), and I've an
elementary question:
I have a vector of spike times from a physiology experiment. I'd
like to create a binned timeseries. For example, suppose my
experiment is 20 msec long and spikes occur at 4, 10, and 15 msec,
and I choose my bin length to be 1 msec. What I'm trying to code is a
way to convert my raw data (a 1x3 array) to a 1x20 array in which
each element is zero, except for the fourth, tenth, and fifteenth,
which would be one.
I attempted to do things this way:
A = zeros(1,20)
m = []
for i = 1:length(A)
t = find(A(i) == 4)
A(t) = 1
end
but this won't work b/c find(A(n)) will not return the index of A(n).
I thought if I could create a vector (A) of (say) 20 zeros, I could
write a script to convert an element in A whose index matched the
value of an element in my raw data to 1. But I can't find a way to say
"if the value of the index is thus, then perform x" only ways to say
"if the value of the element at some index 'n' is thus, then perform
x".
thanks for any suggestions.
aaron
A=zeros(1,20);
SpikeLocations=[4 10 15];
A(SpikeLocations)=1;
.
- References:
- biologist new to matlab
- From: abeyer42
- biologist new to matlab
- Prev by Date: Re: Personal License Password (PLP)
- Next by Date: 'Methlab' t-shirts
- Previous by thread: biologist new to matlab
- Next by thread: binary image denoising
- Index(es):
Relevant Pages
|