MATLAB Matlab: Change Number Format to Remove Decimals

  • Thread starter Thread starter Moly
  • Start date Start date
  • Tags Tags
    Format Matlab
AI Thread Summary
Matlab's default display format can show numbers with four decimal places, which can be undesirable for whole numbers. To change this behavior, users can utilize the command "format short g" in Matlab, which adjusts the display format to show fewer decimal places, effectively eliminating the trailing zeros for whole numbers. This command is recommended for those looking to simplify the numerical output in their matrices.
Moly
Messages
20
Reaction score
0
Hi All

Matlab is displaying numbers with 4 decimal places and i hate when it does that for whole numbers. for example i have a matrix C(i) that starts off from 1 down to 150/275. When i multiply it by 275 i get the first entry as 275.0000 and the last as 150.0000 how do i turn that off or instruct it not to do so.
 
Physics news on Phys.org
Try typing this in Matlab:

Code:
doc format
 
shoehorn said:
Try typing this in Matlab:

Code:
doc format

Thank you for your reply. i tried the first few before posting my question and could not really figure it out. any advice as to which specific option to use?
 
Code:
format short g

should work
 
thanks
 

Similar threads

Replies
3
Views
2K
Replies
4
Views
1K
Replies
2
Views
2K
Replies
8
Views
2K
Replies
2
Views
1K
Back
Top