join cell arrays together

조회 수: 2 (최근 30일)
Osama Alkurdi
Osama Alkurdi 2020년 2월 20일
답변: madhan ravi 2020년 2월 20일
let us assume that I have this cell array
x =
5×1 cell array
{'the_output'}
{'the_output'}
{'the_output'}
{'the_output'}
{'the_output'}
and I have another cell array
y=
5×1 cell array
{[1]}
{[2]}
{[3]}
{[4]}
{[5]}
I want matlab to combine x and y to form, let us say, another cell array called z and it's value
z =
5×1 cell array
{'the_output1'}
{'the_output2'}
{'the_output3'}
{'the_output4'}
{'the_output5'}
I want this to be done without using loops and conditions statements

채택된 답변

madhan ravi
madhan ravi 2020년 2월 20일
cellstr(string(x)+string(y))

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2020년 2월 20일
x=repmat({'the_output'},5,1);
y=mat2cell((1:5)',ones(5,1),1);
z=cellfun(@(a,b) [a,num2str(b)],x,y,'UniformOutput',false)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by