[英]Matlab making new cell array from another cell array fileds
I have a cell array thiscells
: 我有一个单元格数组thiscells
:
thiscells <1*40 cell>
eacharray of thiscells is 280*3
I have a function ( TheFunction
) that gets input of cell array that each array is X*2 我有一个函数( TheFunction
)获取每个数组为X * 2的单元格数组的输入
How can I send a cell array to TheFunction
that contain only columns1,3 from each array? 如何将一个单元格数组发送到TheFunction
,其中每个数组仅包含column1,3?
I tried 我试过了
TheFunction(thiscells{:}(:,1:2)) % tring to send only columns 1,2
But it didn't work 但这没用
Edit: 编辑:
working with (but still looking for faster way to do so): 使用(但仍在寻找更快的方法):
What is did so far 到目前为止做了什么
TheFunction(makingNewCells(thiscells,2));
when 什么时候
makingNewCells:
[newCells]=makingNewCells(oldCells)
for ii=1:max(size(oldcells))
newCells=oldCells(:,[1 column]);
end
This question and its answers may be of help - thiscells{:}(:,1:2)
is already failing without the call to Thefunction
, if I am not mistaken. 这个问题及其答案可能有帮助-如果我没有记错的话,在没有调用Thefunction
, thiscells{:}(:,1:2)
已经失败。
For cells, the problem is even worse: add to this impossibility to double-subref that even if it did what you intended it to do, this passes 40 arguments (which are all 280x2 vectors) to Thefunction
. 对于单元格而言,问题甚至更糟:即使无法做到您打算的目的,也无法对double-subref进行双重引用,这会将40个参数(全部为280x2向量)传递给Thefunction
。 I doubt there are (m)any legitimate uses for a function that takes 40 arguments of the same type, instead of having those wrapped in a cell. 我怀疑该函数是否有(m)个合法用法,这些函数采用40个相同类型的参数,而不是将这些参数包装在单元格中。 I would probably try doc cellfun
first. 我可能会先尝试doc cellfun
。
EDIT: just to be clear, I suggest changing Thefunction
so that it accepts a cell of 40 matrices of size 280x2), then using 编辑:为了清楚Thefunction
,我建议更改Thefunction
,使其接受大小为280x2的40个矩阵的单元格,然后使用
cell_of_twocolumned_arrays = cellfun(@(x)x(:,[1 2]),thiscells)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.