Confusion with adding to cell array
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Harold
am 20 Mai 2013
Kommentiert: Salma Hassan
am 2 Apr. 2020
I have a cell array with the structure as such,
linesegs = [1x2 double] [1x2 double]
I do some calculations on with some other data that is sent to a function within the current program using a function handle. This results in the following structure within the function.
B = [0 0 1 1];
I want insert this array in the next row of linesegs. Basically B would be split into two cells, one containing [0 0] and the other [1 1].
Everything that I've tried seems to be failing.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Amith Kamath
am 20 Mai 2013
This should work:
a = {[0 0], [0 0]}
b = [1 2 3 4]
a{1} = b(1:2) %choose the first two elements from b and assign to first in a.
a{2} = b(3:4) %choose third and fourth
1 Kommentar
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!