Retrieve Spesific Row of Cell Matrix

조회 수: 1 (최근 30일)
Angga Lisdiyanto
Angga Lisdiyanto 2016년 6월 30일
댓글: Angga Lisdiyanto 2016년 6월 30일
Hi, i want to retrieve spesific row data of cell matrix or with a random method. In example :
cell_matrix = {
'i', 'hate', 'war';
'i', 'likes', 'peace';
'i', 'love', 'cats';
}
Then i want below result :
first_row =
'i' 'hate' 'war'
random_row =
'i' 'likes' 'peace'

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 6월 30일
first_row = cell_matrix(1,:);
random_row = cell_matrix(randperm(size(cell_matrix,1),1),:);
or
random_row = cell_matrix(randi(size(cell_matrix,1)),:);

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by