Filter löschen
Filter löschen

How can I control the tolerance in vpasolve?

6 Ansichten (letzte 30 Tage)
Raffaele Di Gregorio
Raffaele Di Gregorio am 14 Dez. 2023
Kommentiert: Dyuman Joshi am 14 Dez. 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?

Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 14 Dez. 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 Kommentare
Raffaele Di Gregorio
Raffaele Di Gregorio am 14 Dez. 2023
Thanks! It works well
Dyuman Joshi
Dyuman Joshi am 14 Dez. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by