Reputation: 302
How I can express a square root for example sqrt(2) in the result of a Matlab computation instead of express the irrational number. For example: sqrt(2) the result should be
2^(1/2)
or
sqrt(2)
instead of
1.4142
Thank in advance!
Upvotes: 1
Views: 1737
Reputation: 22564
If we look at the first two examples on the web page Symbolic Math in Matlab we see that the way to get what you want is
sqrt( sym(2) )
which returns
ans =
2^(1/2)
As the page says,
The key function in Matlab to create a symbolic representation of data is: sym() or syms if you have multiple symbols to make.
Upvotes: 2