필터 지우기
필터 지우기

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

조회 수: 7 (최근 30일)
Linus Dock
Linus Dock 2016년 10월 7일
편집: PARISA SATTAR 2022년 5월 24일
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
Reshad Ahmad Aria Faizy
Reshad Ahmad Aria Faizy 2021년 1월 21일
편집: Reshad Ahmad Aria Faizy 2021년 1월 21일
% 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

댓글을 달려면 로그인하십시오.

답변 (3개)

Massimo Zanetti
Massimo Zanetti 2016년 10월 7일
  댓글 수: 1
Linus Dock
Linus Dock 2016년 10월 7일
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.

댓글을 달려면 로그인하십시오.


Peng
Peng 2018년 12월 1일
% 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 2022년 5월 24일
편집: PARISA SATTAR 2022년 5월 24일
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

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by