フィルターのクリア

How to show exact answers in MATLAB

119 ビュー (過去 30 日間)
Suh-Shin
Suh-Shin 2013 年 9 月 24 日
編集済み: Mr.Gh 2019 年 12 月 14 日
Hello everyone, I run into this exact answer problem with MATLAB pretty frequently. My problem is right now when I'm trying to do an inverse of a matrix containing square roots, it gives me answers in fractions or in decimals. I want it to show the square roots and other functions. How would I go about doing this? I've googled a while and all they say are precision values and rounding and what not, but nothing to do with these square roots.
  2 件のコメント
Karan Gill
Karan Gill 2017 年 11 月 14 日
As Walter answered, use
>> inv([sqrt(sym(21))])
ans =
21^(1/2)/21
Mr.Gh
Mr.Gh 2019 年 12 月 14 日
編集済み: Mr.Gh 2019 年 12 月 14 日
Use this code to see the exact answer:
>>A = inv([sqrt(sym(21))]);
>>answer = double(A)
answer = 2.1822e-01

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

回答 (3 件)

Mahdi
Mahdi 2013 年 9 月 24 日
Why don't you try an approach where you use square the matrix to find out what the numbers are?
For example
MatrixSquared=Matrix.^2;
Then you would be able to see which numbers were square rooted. I would also suggest placing
format rat
before the code.
  1 件のコメント
Suh-Shin
Suh-Shin 2013 年 9 月 24 日
Hey, I tried your approach, but it only gives me fractions. I want MATLAB to show me square roots and powers. I tried the following:
format rat;
inv([sqrt(21)]);
it shows me fractions, but I want to see square roots

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


Matt J
Matt J 2013 年 9 月 24 日
編集済み: Matt J 2013 年 9 月 24 日
Sounds like you're trying to do a symbolic matrix inverse operation. The Symbolic Math Toolbox will let you do that, see
  6 件のコメント
Seetha Rama Raju Sanapala
Seetha Rama Raju Sanapala 2018 年 2 月 9 日
Great clarity, @ Walter Roberson! Thanks.
Karan Gill
Karan Gill 2018 年 2 月 13 日
To add onto Walter's reply, this topic explains differences in arithmetic.

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


Shashank Prasanna
Shashank Prasanna 2013 年 9 月 24 日
Use format to reset your display format or choose a different display format:
>> format
  1 件のコメント
Suh-Shin
Suh-Shin 2013 年 9 月 24 日
format doesn't show the answer in square roots.

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by