How do i assign a random element of an array a new value
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
I have an array maze=strings(size) where all the elements are "0" How did i randomly choose one of these elements and assign it "P"
댓글 수: 0
답변 (2개)
  madhan ravi
      
      
 2018년 10월 31일
        
      편집: madhan ravi
      
      
 2018년 11월 1일
  
      a=maze;
a(randi([1,numel(a)],1,1))='p'
댓글 수: 2
  madhan ravi
      
      
 2018년 10월 31일
				The above shows an example to select random value and replacing it as another.
참고 항목
카테고리
				Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


