How can I concatenate or merge cell in Array

조회 수: 3 (최근 30일)
shaimaa
shaimaa 2022년 8월 23일
이동: Bruno Luong 2022년 8월 24일
dear everyone
can you help me if I have array like (3*3) and I want convert it to ,(1*3) but the array each cell content three numbers for examble if array 3*3is
2 3 5
6 7 6
5 7 1
And 1*3 is
[ 2 6 5 3 7 7 5 6 1]
Best regards
  댓글 수: 3
shaimaa
shaimaa 2022년 8월 23일
dear sir
my array is merge ,I want to convert each column in an array to a unit value while keeping the number of elements as in the example
size([ 2;6;5 3;7;7 5;6;1])]
Rik
Rik 2022년 8월 23일
As you can see, the spaces don't really do anything, I just copied what you wrote to show you the result. Voss showed you how you can split your matrix to a cell vector. If that is not what you want, you need to explain what you do want. Make sure your syntax is valid Matlab syntax, instead of what you wrote in your comment.

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

채택된 답변

Voss
Voss 2022년 8월 23일
A = [2 3 5; ...
6 7 6; ...
5 7 1];
C = num2cell(A,1)
C = 1×3 cell array
{3×1 double} {3×1 double} {3×1 double}
celldisp(C)
C{1} = 2 6 5 C{2} = 3 7 7 C{3} = 5 6 1
  댓글 수: 5
Rik
Rik 2022년 8월 23일
I don't understand what your problem is. The function works the exact same way on a larger array. Just pass your large array as the input argument. Is there still a problem?
shaimaa
shaimaa 2022년 8월 24일
이동: Bruno Luong 2022년 8월 24일
A = [2 3 5; ...
6 7 6; ...
5 7 1];
C = num2cell(A,1)
celldisp(C)
Thank you very it work

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by