how to add a constant to all the elements of the matrix?
272 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
plz help, how to add or multiply a constant value to all the elements of the matrix...
0 Commenti
Risposte (1)
Star Strider
il 1 Mag 2018
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 Commenti
Vedere anche
Categorie
Scopri di più su Operators and Elementary Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!