Matlab: Change Number Format to Remove Decimals

In summary, the conversation is about a user's frustration with Matlab displaying numbers with 4 decimal places and their request for advice on how to turn this off or instruct it not to do so. They are recommended to try the "format short g" option.
  • #1
Moly
21
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
  • #2
Try typing this in Matlab:

Code:
doc format
 
  • #3
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?
 
  • #4
Code:
format short g

should work
 
  • #5
thanks
 

Related to Matlab: Change Number Format to Remove Decimals

1. How do I change the number format in Matlab to remove decimals?

To change the number format in Matlab, you can use the "format" function. For example, to remove decimals, you can use the command "format short" for short numbers or "format long" for longer numbers.

2. Can I specify the number of decimal places to display in Matlab?

Yes, you can use the "format" function with the "short" or "long" options, followed by a number indicating the desired number of decimal places. For example, "format short 2" will display numbers with 2 decimal places.

3. How can I change the number format in Matlab for specific variables?

You can use the "format" function within a specific variable or expression to change its number format. For example, if you want to display a variable "x" with 3 decimal places, you can use the command "format short 3; x" to change the format only for that variable.

4. Is there a way to permanently change the number format in Matlab?

Yes, you can use the "pref" function to permanently change the number format in Matlab. For example, you can use the command "pref('format','short')" to set the default number format to short.

5. Can I change the number format to scientific notation in Matlab?

Yes, you can use the "format" function with the "short e" or "long e" options to display numbers in scientific notation. For example, "format short e" will display numbers in scientific notation with 4 decimal places.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
683
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
995
  • General Math
Replies
1
Views
792
  • Programming and Computer Science
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Replies
8
Views
1K
Back
Top