Effect of period after numeric value
5 views (last 30 days)
Show older comments
MathWorks Support Team
on 18 Jul 2017
Edited: MathWorks Support Team
on 4 Jun 2025
I have the following code:
a = magic(4);
a_divide = a./2.
b = 30.;
c = .0;
Do the periods before or after these values make a difference?
Accepted Answer
MathWorks Support Team
on 3 Jun 2025
Edited: MathWorks Support Team
on 4 Jun 2025
These dot operators are different from the ones preceding mathematical operators which are used for element wise operations for matrices. This operator is used in the portion of code "a./2" but this is not necessary when dividing by a scalar. You can find more information about this operator at the following documentation:
The dot operators in the code you provided has no effect and will functionally be the same without it. You can verify this by using the 'isfloat' function on all of these like so:
a = 1;
b = 1.;
isfloat(a)
isfloat(b)
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!