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
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.
採用された回答
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 Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!