필터 지우기
필터 지우기

How can I control the tolerance in vpasolve?

조회 수: 6 (최근 30일)
Raffaele Di Gregorio
Raffaele Di Gregorio 2023년 12월 14일
댓글: Dyuman Joshi 2023년 12월 14일
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?

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 12월 14일
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
Raffaele Di Gregorio
Raffaele Di Gregorio 2023년 12월 14일
Thanks! It works well
Dyuman Joshi
Dyuman Joshi 2023년 12월 14일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by