Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Indexing (or maybe cellfun?) problem - appending numbers from a vector to rows/cols of cell array

1 vue (au cours des 30 derniers jours)
Arwel
Arwel le 13 Juin 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi Suppose I have a cell array of doubles....
a = { [1] [2] [3] ; [4] [5] [6] }
If I also have a vector....
b = {[6] [7] [8]}
How can I 'append' the vector to a row of the array, so that I end up with...
a = { [1,6] [2,7] [3,8] ; [4] [5] [6] }
I know I could use loops, but in reality a is multidimensional, and both a and b are very large, so the problem is that this takes several hours (in nested loops) at the moment. (I suspect that this may be a matter of clever use of cellfun and maybe a custom inline function, rather than indexing though...but I just can't figure it!) Cheers, Arwel

Réponses (1)

Andrei Bobrov
Andrei Bobrov le 13 Juin 2013
a(1,:) = cellfun(@(x,y)[x,y],a(1,:),b,'un',0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by