Could anyone help me to solve the issue.

조회 수: 1 (최근 30일)
jaah navi
jaah navi 2019년 9월 13일
댓글: madhan ravi 2019년 9월 19일
I am having matrix
A=[1 2;
2 3;
2 4]
when i use the command
NN = num2cell(num2cell(A),2)
partdisp(NN)
i am getting the result as
NN =
{1x2 cell}
{1x2 cell}
{1x2 cell}
The formation of clusters :
{1} {2}
{2} {3}
{2} {4}
but i need to have the result in the following manner
NN =
{1x1 cell}
{1x1 cell}
{1x1 cell}
The formation of clusters :
{1 2}
{2 3}
{2 4}
could anyone please help me on it.

채택된 답변

madhan ravi
madhan ravi 2019년 9월 13일
편집: madhan ravi 2019년 9월 13일
NN = num2cell(num2cell(A,2),2)
  댓글 수: 4
jaah navi
jaah navi 2019년 9월 19일
ok.But is there any other way to have random combinations like {2 3}{4 1 5} {6} {7} other than { 2 3 4 1 5 6 7} or {2} {3} {4} {1} {5} {6} {7}.
madhan ravi
madhan ravi 2019년 9월 19일
mat2cell(A,[1,1,1],[2,3,1,1]) % see the documentation and learn how to use it

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

추가 답변 (1개)

Fabio Freschi
Fabio Freschi 2019년 9월 13일
For your case
NN = mat2cell(A,[1 1 1],2)
A bit more general
NN = mat2cell(A,ones(size(A,1),1),size(A,2))
  댓글 수: 5
Fabio Freschi
Fabio Freschi 2019년 9월 13일
Not my case. Just running the code before posting
Adam
Adam 2019년 9월 13일
Yeah, even just opening a question and typing your answer can take long enough that when it's posted there are 2 or 3 other answers too. It's perfectly fine though.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by