merge multiple cells in only one
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Alberto Acri
il 8 Set 2023
Commentato: Alberto Acri
il 9 Set 2023
Hi! How can I merge these two cells?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1476911/image.png)
Final results:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1476956/image.png)
3 Commenti
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:
Risposta accettata
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)
In case you want to store them as 4x6 as well -
out2 = vertcat(value1,vertcat(value2{:}))
3 Commenti
Dyuman Joshi
il 9 Set 2023
Store the data in an array and use indexing to access the data -
mat1 = load('value1.mat');
value1 = mat1.value1;
mat2 = load('value2.mat');
value2 = mat2.value2;
out1 = vertcat({value1},value2)
variable = vertcat(out1{:})
Here, variable_k will correspond to the kth row of variable.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Workspace Variables and MAT-Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!