merge multiple cells in only one

10 visualizzazioni (ultimi 30 giorni)
Hi! How can I merge these two cells?
Final results:
  3 Commenti
Stephen23
Stephen23 il 8 Set 2023
@Alberto Acri: note that storing scalar strings in cell arrays is very inefficient, and it avoids all of the benefits of using string arrays. You should be using string arrays, just as the documentation recommends:

Accedi per commentare.

Risposta accettata

Dyuman Joshi
Dyuman Joshi il 8 Set 2023
As you want the final result to be a 4x1 cell array -
mat1 = load('value1.mat');
value1 = mat1.value1;
mat2 = load('value2.mat');
value2 = mat2.value2;
out1 = vertcat({value1},value2)
out1 = 4×1 cell array
{1×6 cell} {1×6 cell} {1×6 cell} {1×6 cell}
In case you want to store them as 4x6 as well -
out2 = vertcat(value1,vertcat(value2{:}))
out2 = 4×6 cell array
{["54"]} {["55"]} {["56"]} {["57"]} {["58"]} {["59"]} {["60"]} {["61"]} {["62"]} {["63"]} {["64"]} {["65"]} {["66"]} {["67"]} {["68"]} {["69"]} {["70"]} {["71"]} {["72"]} {["73"]} {["74"]} {["75"]} {["76"]} {["77"]}
  3 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Numeric Types in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by