how to add a constant to all the elements of the matrix?
272 ビュー (過去 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 で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!