how to get matrix value right?

1 次查看(过去 30 天)
i am working on transferring some values to a matrix from another one. when i am printing the results individually like new(1,1) its showing exact result, but when printing whole new its giving totally wrong answer with (1.0e+003 *) on above.how to solve the problem?
new(row,col)=newMatrix(l,k,m); disp(new(1,1));-gives right answer but- disp(new); gives all wrong.

采纳的回答

Stephen23
Stephen23 2015-8-15
编辑:Stephen23 2015-8-17
Actually MATLAB is displaying the correct values, but they are simply being displayed using scientific notation. Scientific notation is a very common convenient way to write large/small numbers, without using lots of digits. Lets have a look at some simple examples:
>> 1000000000 % one with nine zeros
ans =
1.0000e+09
>> 1e9 % easier to input it like this
ans =
1.0000e+09
And if the values are in an array, then a common exponent is placed above the displayed values (it becomes a factor of all of the values displayed in the array below it):
>> [1e9,2e10]
ans =
1.0e+10 *
0.1000 2.0000
This is the correct behavior, not an error. You can find more information about scientific format on the the internet. If you want to change how the values are displayed, then have a look at format, and try some of the options until you find one that you like:
>> format longG
>> [1e9,2e10]
ans =
1000000000 20000000000
Note that the docs suggest that shortG might be suitable for data that has a wide range of values.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by