Use of CELLFUN instead of FOR loop
Show older comments
I have a 21x40 cell array with each cell containing a vector of variable length. I want to merge all of the cells in each column. I can achieve this using a FOR loop such as
A = 21x40 cell array
for n = 1:40
merge = cat(2,A{:,n})
end
How can I do this with, for example, CELLFUN or in some other way without using a FOR loop? Thanks a lot for any help.
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 9 Jun 2013
for n = 1:40
merge = cat(2,A{:,n})
end
is the same then
merge = cat(2,A{:,40})
4 Comments
Neil
on 9 Jun 2013
Azzi Abdelmalek
on 9 Jun 2013
That's what your code, also do
Neil
on 9 Jun 2013
Azzi Abdelmalek
on 9 Jun 2013
Edited: Azzi Abdelmalek
on 9 Jun 2013
Your for loop should be: (merge{n} instead of merge)
for n = 1:40
merge{n}= cat(2,A{:,n})
end
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!