How to separate cell rows in different cell??

I want to separate like this A = cell row 1 B = cell row 2 etc.. how can possible??? please help me and thanks

 채택된 답변

James Tursa
James Tursa 2018년 4월 11일
편집: James Tursa 2018년 4월 11일

0 개 추천

Do you mean like this?
A = yourcell(1,:);
B = yourcell(2,:);
:
etc
But if you have lots of rows to deal with, or an unknown number of rows that your code will need to deal with, it would be better to leave it all in the original cell variable and then just use the (k,:) row indexing method downstream in your code.
EDIT:
To get rid of the empty cells, e.g.,
A = yourcell(1,:);
A(cellfun(@(x)isempty(x),A)) = [];
or
A = yourcell(1,cellfun(@(x)~isempty(x),yourcell(1,:)));
How many rows will you have to deal with? If there could be a lot, then again I would advise that you encapsulate all of this in another cell matrix instead of creating lots of variables named A, B, etc.

댓글 수: 5

Amrita Datta
Amrita Datta 2018년 4월 11일
thank you sir...its working
Amrita Datta
Amrita Datta 2018년 4월 11일
편집: James Tursa 2018년 4월 11일
this problem solve but i want exactly like this
A is 4x2 matrix create
A = [101.3193 29.1525,
26.2377 28.4059,
26.0686 12.9270,
55.2045 4.6625]
A = cell2mat(A(:));
Amrita Datta
Amrita Datta 2018년 4월 11일
thank you sir....

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

추가 답변 (1개)

Jan
Jan 2018년 4월 11일

0 개 추천

Creating a bunch of variables dynamically is a bad idea, see Tutorial: Why to avoid EVAL. Using indices is much smarter:
C(2, :)
This is a cell, which contains the 2nd row already. Using a new variable to copy this contents to a specific variable.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2018년 4월 11일

댓글:

2018년 4월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by