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!