0

我正在尝试编写代码以提取 1x1000 的数据向量,这些值的倍数变化为 2 或更多。倍数变化 2 相当于 -1。我想提取我的基因名称(在向量 C 中编码)和值(在向量 fcsites 中编码)。到目前为止,这是我想出的,但我的问题之一是我不知道将什么指定为新向量的长度。有谁知道更好的方法来解决这个问题?

atleast = {C,fcsites}
Z = zeros(length(C),1);
for i2=1:length(C)
Z(i2)=C(fcsites<=-1);
end

我得到错误:

atleast = 

    {602x1 cell}    [602x1 double]

The following error occurred converting from cell to double:
Error using double
Conversion to double from cell is not possible.
4

1 回答 1

0

Find the desired elements in fcsites, and use their corresponding indices as a subscript for C:

idx = (fcsites <= -1);
X = C(idx)

or shorter:

X = C(fcsites <= -1)

Now X contains all the names from C that correspond to values in fcsites that are less than or equal to -1.

于 2013-03-19T18:25:32.567 回答