how to avoid powers of 10 i.e 1.0e+03 in answers

Hello, every time when i done calculation matlab giving answers 1.0e+03 * [ vector]. how to avoid this..??? few times its useful but few times it troubles me.

 Réponse acceptée

Walter Roberson
Walter Roberson le 5 Juin 2015
Modifié(e) : Walter Roberson le 5 Juin 2015

5 votes

"format short" or "format long". See also your Preferences -> Command Window Preferences, as the default can be set there.

6 commentaires

Guillaume
Guillaume le 5 Juin 2015
format shortg or format longg is better at getting rid of the scientific notation.
Thank you "format shortg" done the trick. just a small doubt, how did i have to know that which format right now am working on.
Stephen23
Stephen23 le 5 Juin 2015
Modifié(e) : Stephen23 le 5 Juin 2015
The documentation will probably help you:
The table Numeric Format gives a list of all options: try them!
I have the same issue but the above answers are missing some bits. Solution is clear but how to apply "format long g" to the project ? Should I run the simulation again or it converts the variables in the workspace immediately, i.e as soon as I prompt it in the command window ? I've tried a couple of steps but none of them seem to work...
Stephen23
Stephen23 le 30 Mai 2018
@Maximilian Arpaio: the format is a property of the command window. It affects how numeric values are displayed in the command window. You can set the format and then after that all numbers will be displayed using the format that you selected, until you change it again. The format is not a property of projects or functions (although it might be set by them).
Thank you so much for giveing these command, this is very useful, when other operations are applied on these numbers.

Connectez-vous pour commenter.

Plus de réponses (3)

Use
format shortG
>> 1.0e+03
ans =
1000

1 commentaire

Far out, thank you my man! It's seriously irritating enough then I tend to use symbolab instead of matlab

Connectez-vous pour commenter.

Hi my script is this
n=[1.5,3.4;91250,73000]
but it comes out as
n =
1.0e+04 *
0.0001 0.0003
9.1250 7.3000
the 1.0e+04 * automatically comes out of nowhere and disturbs my data all the time. Anyone knows why?

1 commentaire

for the reasons discussed above. Give the command
format long g
and display the data again

Connectez-vous pour commenter.

Sren Seyha
Sren Seyha le 9 Avr 2020

1 vote

How avoid exponnetial number in my matlab gui interface:

1 commentaire

If you are looking at the variable browser, then you can use Preferences -> Variables -> Default array format to change to a different format for the variable browser. For values that are being output by disp() or implied disp() to the command window then Preferences -> Command Window -> Text Display -> Numeric Format sets the "format" command that is done for you when you start MATLAB.
If you are talking about numeric data that is entered into a uitable(), then the only control you have is to set the ColumnFormat property for the column to one of the format types such as 'longg' . However you cannot use a standard format specification such as %0.7f . If you need that level of control, then best is to sprintf() or sprintfc() or compose() to convert the numbers to character vectors or string objects and set that into the uitable.
If you are talking about numeric data that you are setting as a String property of a uicontrol listbox or popup, then use sprintf() or sprintfc() or compose() to format it before setting it as the String property.

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by