how to add a constant to all the elements of the matrix?
    조회 수: 158 (최근 30일)
  
       이전 댓글 표시
    
plz help, how to add or multiply a constant value to all the elements of the matrix...
댓글 수: 0
답변 (1개)
  Star Strider
      
      
 2018년 5월 1일
        Since ‘implicit expansion’ arrived in R2016b, this will work:
A = rand(3);
B = A + 5;
or:
B = A * 5;
For all releases, using bsxfun will work:
B = bsxfun(@plus, A, 5);
or:
B = bsxfun(@times, A, 5);
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

