biologist new to matlab



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

.



Relevant Pages

  • Re: biologist new to matlab
    ... I have a vector of spike times from a physiology experiment. ... 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, ... value of an element in my raw data to 1. ...
    (comp.soft-sys.matlab)
  • Re: Arrays of zero length
    ... The minor strangeness is that when you allocate an array to zero size, ... saying something like that allocating an array makes it undefined ... In f77, zero-size was disallowed, ...
    (comp.lang.fortran)
  • Re: should every thing be zero indexed?
    ... Other families of languages count from 1. ... its number is zero: I always start counting at zero". ... > as a fundamental concept in both the definition of array indices and ... > for I in foo'range loop ...
    (comp.programming)
  • Re: Subset Sum problem (w/ limited scope)
    ... The "Subset Sum" problem (stated various ways depending on what you ... a subset of those integers that sums up to zero. ... Are there going to be duplicate values in your original array? ...
    (comp.lang.fortran)
  • Re: addEvent - The late entry :)
    ... take any number of arguments and append them to an array. ... argument, which is fine on everything but Firefox, where it makes the ... 20 arguments Windows Safari 3 executes that expression in 48% of the ... and at zero arguments 47%. ...
    (comp.lang.javascript)