필터 지우기
필터 지우기

how to add a constant to all the elements of the matrix?

조회 수: 569 (최근 30일)
hp
hp 2018년 5월 1일
답변: Star Strider 2018년 5월 1일
plz help, how to add or multiply a constant value to all the elements of the matrix...

답변 (1개)

Star Strider
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);

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by