Borrar filtros
Borrar filtros

How to display all valid results when converting fraction form to decimal form? Specifically when the fraction expression includes roots of negative numbers.

1 visualización (últimos 30 días)
For example, (-1)^(1/3)+2 is something what I got from subsituting varibles into a symbolic equation, and I would like to see all the complex results and eliminate ones that have imaginary components.

Respuestas (1)

Gargi Patil
Gargi Patil el 15 de Abr. de 2021
To view all the roots of an expression, you can use the function roots().
The following code returns all the roots of (-1)^(1/3)+2:
allRoots = 2 + roots([1 0 0 1]);
To obtain only the nth real root, the function nthroot() can be used.
The following code returns the real root for the expression (-1)^(1/3)+2:
realRoots = 2 + nthroot(-1, 3);

Categorías

Más información sobre Argument Definitions en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by