assign vector to cell
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MatteP
am 26 Mai 2016
Beantwortet: Jos (10584)
am 26 Mai 2016
I have a vector k, whose length is N.
I have created an empty cell(N,M)=New
Is there a clever way to assign the values of the vector to the first column of the cell? I mean something whose outcome is the same as
for j=1:N
New{j,1}=k(j)
end
Thanks
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Jos (10584)
am 26 Mai 2016
num2cell is just the loop you wrote hidden behind a function. Nothing to gain there, I would say.
Just for fun, you could also abuse arrayfun:
k = 10:10:100
C = arrayfun(@(x) x, k, 'un',0)
0 Kommentare
Andrei Bobrov
am 26 Mai 2016
Bearbeitet: Andrei Bobrov
am 26 Mai 2016
New = num2cell(k)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!