Creating a vector out of variables

131 ビュー (過去 30 日間)
Daniel Miller
Daniel Miller 2019 年 9 月 16 日
コメント済み: Star Strider 2019 年 9 月 16 日
Hello!
This might seem very simple, but if I have created, let's say, the following variables:
A = 1/(10^(-6));
B = 22^(1/4);
C = 4^(3+2);
Now, I should make a vector (named MySolutions) containing the solutions A to C.
Shouldn't it work by writing:
MySolutions = [A,B,C]
The output gives me:
mySolution =
1.0e+06 *
1.0000 0.0000 0.0010
I don't understand why the output looks so weird.
Any help is appreciated!

採用された回答

Star Strider
Star Strider 2019 年 9 月 16 日
Use the format function to change the way they are displayed:
A = 1/(10^(-6));
B = 22^(1/4);
C = 4^(3+2);
format long E
MySolutions = [A,B,C]
format short g
MySolutions = [A,B,C]
format long
MySolutions = [A,B,C]
producing:
MySolutions =
1.000000000000000e+06 2.165736770667994e+00 1.024000000000000e+03
MySolutions =
1e+06 2.1657 1024
MySolutions =
1.0e+06 *
1.000000000000000 0.000002165736771 0.001024000000000
  2 件のコメント
Daniel Miller
Daniel Miller 2019 年 9 月 16 日
Thank you for such a quick answer! Cheers!
Star Strider
Star Strider 2019 年 9 月 16 日
As always, my plesure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by