How can I merge multiple cells of data into one cell?

21 visualizzazioni (ultimi 30 giorni)
Hi, I have a cell containing several cells of output data on the form:
'METAR ESDF 200807010020Z AUTO 31003KT 230V350 9999NDV NCD 12/08 Q1017'
The outer cell looks like this:
<1x6cell>
and the inner ones like this:
<1250x1cell> <1500x1celll> ...and so on
I would like to merge these inner cells to have all my data inside one cell. Is there an easy solution to this problem?
Thank you!
  1 Commento
Reshad Ahmad Aria Faizy
Reshad Ahmad Aria Faizy il 21 Gen 2021
Modificato: Reshad Ahmad Aria Faizy il 21 Gen 2021
% A is your cell which contains many cell
% B , where you want to put them all
k=0;
for i=1:size(A,1)
j = size (A{i,1},1);
B (k+1:j+k,:) = A{i,1};
k = size(B,1);
end
ref:@Ali Pourzangbar

Accedi per commentare.

Risposte (3)

Massimo Zanetti
Massimo Zanetti il 7 Ott 2016
  1 Commento
Linus Dock
Linus Dock il 7 Ott 2016
Ok thanks for the information! But I need to obtain one cell with the data from my many cells (actually around 100). The data I have looks like this:
Utdata =
{1255x1 cell}
{1487x1 cell}
{1447x1 cell}
{1464x1 cell}
{1433x1 cell}
{1500x1 cell}
...and so on
and I would like the output like this
Utdata =
{manyrowsx1 cell}
How can this be done in a simple manner? After this step I would like to save my Utdata into a .xlxs file for easy overview, but that is pretty straightforward.

Accedi per commentare.


Peng
Peng il 1 Dic 2018
% transfer a nested cell array to a cell array
SEGS = {{rand(2,1);rand(3,1)};...
{rand(4,1);rand(5,1);rand(6,1)};...
{rand(7,1);rand(8,1);rand(9,1);rand(10,1)}};
A = SEGS{1};
for k = 2:size(SEGS,1)
A = [A;SEGS{k}];
end
SEGS =
{2x1 cell}
{3x1 cell}
{4x1 cell}
A =
{9x1 cell}

PARISA SATTAR
PARISA SATTAR il 24 Mag 2022
Modificato: PARISA SATTAR il 24 Mag 2022
Data1=struct2array(load(input('enter the name of first cell:\n','s')));
Data2=struct2array(load(input('enter the name of 2nd cell:\n','s')));
l1=length(Data1);
l2=length(Data2);
l=l1+l2;
j=1
for i=1:l;
if i<=l1
R_peak_Locations_N2_CG_RBDid{i,1}=Data1{i,1}
else
R_peak_Locations_N2_CG_RBDid{i,1}=Data2{j,1}
j=j+1;
end
end

Community Treasure Hunt

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

Start Hunting!

Translated by