find a rows in matrix and its position in that matrix ?

조회 수: 1 (최근 30일)
MUKESH KUMAR
MUKESH KUMAR 2017년 11월 22일
댓글: MUKESH KUMAR 2017년 12월 12일
datasheet(48*6)size
%I had a matrix of size(48*6) and then
ii = randperm(size(datasheet,1));
k = ones(24,1)*2;
out = mat2cell(datasheet(ii(1:sum(k)),:),k,size(datasheet,2));
%then i select a row from datasheet lets say 4th row
B=datasheet(4,:);
%now I want to find out the position of that 4th row in "out" matrix.

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 22일
out{ ceil( find(ii == 4)/2 ) }
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 11월 22일
Row ceil( find(ii == 4)/2 )
MUKESH KUMAR
MUKESH KUMAR 2017년 12월 12일
If I have updated K and datasheet values like attached file then I did not find according to this code and I also tried Index/find but did not get

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 11월 22일
편집: Andrei Bobrov 2017년 11월 22일
In general case:
[~,ji] = cellfun(@(x)ismember(B,x,'rows'),out,'un',0);
jj_cell = find(cellfun(@(x)x>0,ji));
ii_row_in_cell = ji{jj_cell};

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by