How can I remove the power of a matrix?

3 ビュー (過去 30 日間)
Jaybee
Jaybee 2014 年 3 月 12 日
編集済み: Niklas Nylén 2014 年 3 月 12 日
say i performed some calculations and the answer was:
A =
1.0e+06 *
0.0001 55 100
0.0002 66 110
0.0003 77 120
0.0004 88 130
how can I remove "1.0e+06 *" and reduce it to its normal form?

採用された回答

Niklas Nylén
Niklas Nylén 2014 年 3 月 12 日
編集済み: Niklas Nylén 2014 年 3 月 12 日
I made a script that allows you to print a matrix to the command window with a selected precision, see attached file.
The script is mostly for aligning axes and data in tables for use in parameter files, so you can probably remove some of the code if you do not need perfect alignment.
% printmat(A,precision)
% Prints the values in the matrix A with the desired precision in the command window.
  2 件のコメント
Mischa Kim
Mischa Kim 2014 年 3 月 12 日
Not sure, I understand...
format longeng
A = 1e3*[0.000000000001 1.2e12 1e-18]
A =
1.00000000000000e-009 1.20000000000000e+015 1.00000000000000e-015
Niklas Nylén
Niklas Nylén 2014 年 3 月 12 日
編集済み: Niklas Nylén 2014 年 3 月 12 日
I thought he meant he wanted the numbers printed without the e notation, i.e.
[100 55000000 100000000
200 66000000 110000000
300 77000000 120000000
400 88000000 130000000]
For the specific case in the question, format long works, but for very snall or very large numbers matlab will use the e notation anyway.
(Before my edit I mixed up format longeng and format long g, if that was what you did not understand)

サインインしてコメントする。

その他の回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 3 月 12 日
編集済み: Mischa Kim 2014 年 3 月 12 日
Jaybee, execute, e.g.
format longeng
in the command window. Or use any other formatting option.

Chris C
Chris C 2014 年 3 月 12 日
So, the reason Matlab displays data in that manner is to make the best use of the available real estate. However, if you still find the need to express the data in a different manner. Use the Matlab documentation under the title "Format". An example would be...
A = 1.0e+06*[0.0001,55,100;0.0002,66,110;0.0003,77,120;0.0004,88,130];
format long
A =
100 55000000 100000000
200 66000000 110000000
300 77000000 120000000
400 88000000 130000000

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by