Create a logical vector

143 ビュー (過去 30 日間)
PAK
PAK 2018 年 8 月 2 日
コメント済み: PAK 2018 年 8 月 3 日
Hi All,
I have a cell array, where each cell in the first row contains a double of various lengths. Each double corresponds to sample numbers where a spike occurs (from a neuron - variable called cluster_split). I also have created an array of 0's the length of signal I am interested in (variable called LFP). I would like to index across each double (i.e.: cluster_split{1,1}) and create a logical vector of 1's and 0's.
For example, if in cluster_split{1,1} there is a value equal to 2502 (corresponding to sample 2502 in the LFP vector), then Matlab would output a 1 to the LFP array. I would like to create a separate "LFP" file for every double in the cluster_split cell array.
Thanks in advance for the help!
PK

採用された回答

Adam Danz
Adam Danz 2018 年 8 月 2 日
編集済み: Adam Danz 2018 年 8 月 2 日
Does this help?
LFP = false(1, 3000);
LFP(2500) = true;
If LFP is at millisecond resolution and a spike occurs at 2500 milliseconds, you'll see a 1 in position 2500. Since I used true/false the vector is logical.
  9 件のコメント
Adam Danz
Adam Danz 2018 年 8 月 3 日
編集済み: Adam Danz 2018 年 8 月 3 日
Does each array cluster_class{n} have the same size? In other words, are all cell arrays stored in cluster_class the same length? If so, this code can be simplified.
In any case, what is the value of 'clusters'? I think what you want is something like this
LFP = false(length(cluster_class), test);
for i = 1:length(cluster_class)
LFP(cluster_class{i}) = true;
end
PAK
PAK 2018 年 8 月 3 日
Hi Adam,
Each array is not the same size. The value of 'clusters' is [1,2,3,4,5,6,7,8]. Essentially the row length of cluster_class{n}. The following code below works!
LFP_size = size(data,2);
for i = clusters
LFP(i, :) = false(1, LFP_size);
LFP(i,cluster_split_recalled_samples{i}) = true;
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBehavior and Psychophysics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by