Effacer les filtres
Effacer les filtres

Can vpasolve restrict the numerical solution to be a real number? If it can, how should I stipulate this condition?

33 vues (au cours des 30 derniers jours)
I have eight unknown variables and eight equations. Now I use the vpasolve to find the numerical solution of the equation, hoping to get only the real solution, but the vpasolve only returns a complex solution. Can I restrict the it to output only real solutions? If I can, how should I implement it? Thank you for your reply.

Réponses (2)

Dyuman Joshi
Dyuman Joshi le 24 Avr 2022
syms x
S = vpasolve(x^6 - x^2 == 3, x)
S = 
assume(x,'real')
S = vpasolve(x^6 - x^2 == 3, [-Inf Inf])
S = 

jessie sun
jessie sun le 25 Avr 2022
Dear @Dyuman Joshi, I used "assume" to restrict the unknown variables to be real numbers:
But the output result was not as I expected:
  3 commentaires
Walter Roberson
Walter Roberson le 25 Avr 2022
Tips:
vpasolve ignores assumptions set on variables. You can restrict the returned results to particular ranges by specifying appropriate search ranges using the argument init_param.
jessie sun
jessie sun le 25 Avr 2022
Thank you for your answer. By using your method, the problem has been solved.@Dyuman Joshi@Walter Roberson

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by