フィルターのクリア

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

272 ビュー (過去 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 Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by