简体   繁体   English

级联细胞

[英]Concatenate cells

I have two cells, 我有两个牢房

A =
 [100x2 double]    [80x2 double]    [50x2 double]
B =
 [100x5 double]    [80x5 double]    [50x5 double]

How can I Concatenate them to get something like C = cat(2,A,B) for each array. 我如何将它们连接起来以获得每个数组类似C = cat(2,A,B)的东西。 C must be, C一定是

C =
 [100x7 double]    [80x7 double]    [50x7 double]

Thanks, 谢谢,

C = cellfun(@(a, b) [a b], A, B, 'UniformOutput', false);

This will create the cell array C for you. 这将为您创建单元阵列C。

Example: 例:

>> A = { zeros(100,2), zeros(200,2) };
>> B = { ones(100,5), ones(200,5)};
>> C = cellfun(@(a, b) [a b], A, B, 'UniformOutput', false);

You probably need some kind of loop: 您可能需要某种循环:

C = arrayfun(@(n) [A{:,n} B{:,n}], 1:numel(A), 'uniformoutput', 0);

Of course, if the number of cells in A (and B ) is fixed, you can replace the loop by an enumeration: 当然,如果A (和B )中的单元格数目是固定的,则可以用枚举代替循环:

C = {[A{:,1} B{:,1}] [A{:,2} B{:,2}] [A{:,3} B{:,3}]};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将多个单元格的公式组合成一个单元格 - concatenate formula formation of multiple cells into one cell UIPATH - 连接数组中的两个 excel 单元 - UIPATH - Concatenate two excel cells in an array Matlab:将所有单元格连接到一个矩阵 - Matlab: concatenate all cells to one matrix 在导入查询中将两个单元格连接在一起 - Concatenate two cells together on an import query 使用带有 TEXTJOIN 的数组函数连接多个单元格,但具有多个条件? - Using an Array Function with TEXTJOIN to concatenate multiple cells, but with multiple criteria? 将每行中的非空单元格与谷歌表格中的 arrayformula 连接起来 - Concatenate non empty cells in each row with arrayformula in google sheets Google Sheets - 根据相应单元格范围内的数值连接单元格范围内文本的公式 - Google Sheets - Formula to Concatenate Text in Range of Cells based on Numeric Value in Corresponding Range of Cells VBA 将字符串与前一个字符串值连接起来(前一个值每隔几个单元格更改一次) - VBA Concatenate string with previous string value (previous value changes every few cells) 如何连接单元阵列(阵列中的15个单元,每个单元大约1x7500) - How to concatenate a cell array (15 cells in an array, each are around 1x7500) 在Excel的value_if_true字段中,我有一个串联公式。 它对于第一个单元格工作正常,但是当我将其拖动到其他单元格时会混乱 - In Excel in value_if_true field i have a concatenate formula. It works fine for first cell but messes up when i drag it to other cells
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM