concatenation from 2 differents cell arrays

1 次查看(过去 30 天)
Hello everyone,
I am trying to find an answer on the forum to my problem but I don't find any solution, so here is my problem. As I am a beginner the solution maybe very simple.
I'm processing data from experiment and at one point I have two cell arrays that I want to concatenate considering that the length of the cell can vary from one set of data to another.
for example:
bloc_base contains seven 3-D matrix (x,z,t) and,
bloc_fix contains seven 3-D matrix (x,z,t)
for a known set of data I can do :
new_vector = cat(3, bloc_base{1}, bloc_fix{1},bloc_base{2}, bloc_fix{2},...,bloc_base{7}, bloc_fix{7});
the number of 3-D matrix contained in the cell array can vary from one set of data to another so I try to write a script that can take this info into account to concatenate the data into a new vector. I have tried to use a for loop but I didn't manage to get good result...
If you have any ideas !
thanks
Alex
  2 个评论
Stephen23
Stephen23 2016-5-9
编辑:Stephen23 2016-5-9
@AlexDiz: you write that you "have two structures array", but then you use cell array indexing in your example. These are two very different things! Communicating on this forum is a lot easier when everyone uses the correct terminology: can you please check and confirm if you are using a structure or a cell array.
AlexDiz
AlexDiz 2016-5-9
yes you are right, I have modified the message, these are cell array thank you

请先登录,再进行评论。

采纳的回答

Stephen23
Stephen23 2016-5-9
编辑:Stephen23 2016-5-9
You don't give sizes of bloc_base and bloc_fix, but for your cell arrays (?) you could try something like this:
C = [bloc_base(:)';bloc_fix(:)'];
out = cat(3,C{:});
Here is a complete working example:
>> A = {[1,2],[3,4],[5,6]};
>> B = {[9,8],[7,6],[5,4]};
>> C = [A;B];
>> cat(3,C{:})
which uses this feature to use the cell array elements as separate input arguments:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by