Effacer les filtres
Effacer les filtres

How can I control the tolerance in vpasolve?

6 vues (au cours des 30 derniers jours)
Raffaele Di Gregorio
Raffaele Di Gregorio le 14 Déc 2023
Commenté : Dyuman Joshi le 14 Déc 2023
I am using vpasolve to solve a system of seven equations in seven unknowns.
I have a set of data that solve the system with a tolerance of 0.1e-3 (that is, the tolerance with which the absolute value of the difference between the left-hand side and the right-hand side of each equation is equal to zero). Such a tollerance is OK for my applications, but, unfortunately, vpasolve uses as default tolerance a tighter value and it is not able to find the solutions of my system.
How can I control the tolerance in vpasolve?

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 14 Déc 2023
Here is one example show how to adjust vpasolve tolerance:
syms x
EQN = sin(2*x) == 0.5;
% Default
sol_D= vpasolve(EQN,x)
sol_D = 
0.26179938779914943653855361527329
% Controlled using digits()
N = 3;
digits(N)
sol_C= vpasolve(EQN,x)
sol_C = 
0.262
  2 commentaires
Raffaele Di Gregorio
Raffaele Di Gregorio le 14 Déc 2023
Thanks! It works well
Dyuman Joshi
Dyuman Joshi le 14 Déc 2023
This just changes the number of significant digits of the output. It does not satisfy the tolerance, see below.
And I don't think vpasolve() uses any tolerance to solve.
syms x
EQN = sin(2*x) == 0.5;
% Default
sol_D= vpasolve(EQN,x);
% Controlled using digits()
N = 3;
digits(N)
sol_C= vpasolve(EQN,x)
sol_C = 
0.262
isAlways(abs(0.5-sol_C)<10^-N)
ans = logical
0

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by