필터 지우기
필터 지우기

Concatenate Cell array of doubles along rows

조회 수: 2 (최근 30일)
Abdelrahman Abdeltawab
Abdelrahman Abdeltawab 2016년 11월 5일
편집: Walter Roberson 2016년 11월 5일
i have a cell array that looks like the following (4X2) in attached image
I want to concatenate adjacent values in rows

채택된 답변

Walter Roberson
Walter Roberson 2016년 11월 5일
arrayfun(@(COLIDX) vertcat(YourCell{:,COLIDX}), 1:size(YourCell,2), 'Uniform', 0)
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 11월 5일
arrayfun(@(ROWIDX) vertcat(YourCell{ROWIDX,:}), (1:size(YourCell,1)).', 'Uniform', 0)
Abdelrahman Abdeltawab
Abdelrahman Abdeltawab 2016년 11월 5일
편집: Walter Roberson 2016년 11월 5일
One more thing Mr. Walter to enhance the below function to incoprate your current answer, given that (please look at attached images in zip file)
function CombinedCurves= PrepareCombineCurvesCells(CurvesCell,selectedCurves,currWellNames)
fnames=fieldnames(CurvesCell);
n=cell(numel(selectedCurves)*numel(currWellNames),1);
for cWCurve=1:numel(selectedCurves)
for currWell=1:numel(fnames)
n{cWCurve,currWell}= CurvesCell.(fnames{currWell}).(selectedCurves{cWCurve});
end
end
CombinedCurves=n ;
end

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

추가 답변 (1개)

KSSV
KSSV 2016년 11월 5일
Let C be your cell array..
iwant{1} = [C{1,1} C{2,1}] ;
iwant{2} = [C{1,2} C{2,2}] ;
  댓글 수: 2
Abdelrahman Abdeltawab
Abdelrahman Abdeltawab 2016년 11월 5일
Thanks KSSV but my case is dynamic case so items might increase ,or decrease i cannot hard code indices like this
KSSV
KSSV 2016년 11월 5일
You can put that into loop....not a big deal.

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by