How to select specific row in a matrix
    조회 수: 8 (최근 30일)
  
       이전 댓글 표시
    
Hi all..
i have a problem to select every row.
for eg:
i have matrix 100x13.
i want to select data which position in row 1-5, 21-25, 41-45, 61-65, 81-85.
so i have 2 new matrixs. first as i described above, and the second is the rest (6-20, 26-40, 46-60, 66-80, 86-100).
i want to apply k-fold method to get training data and testing data.
thanks a lot if somebody can help me.
regards
Ikra
댓글 수: 0
답변 (2개)
  Shashank Prasanna
    
 2013년 2월 11일
        A = rand(100,4);
ind_logical = logical(ones(100,1));
ind_logical([1:5, 21:25, 41:45, 61:65, 81:85])=false;
B = A(~ind_logical,:);
C = A(ind_logical,:);
댓글 수: 2
  Jan
      
      
 2013년 2월 11일
				true(100, 1) is more efficient than creating a double array at first and convert it ino a logical. But the logical indexing is an efficient method here in general: +1.
참고 항목
카테고리
				Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
			
	제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



