Solve is not providing correct solution
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to solve the below equation which is a part of a transfer function calculation.
clear
syms a b c d k
Hhf=6;
Q=3;
Coeff2=0;
Coeff3=0;
assume(a,["positive","real"]);
assume(b,["positive","real"]);
assume(c,["positive","real"]);
assume(d,["positive","real"]);
assume(k,["positive","real"]);
eq1=vpa(a==10^(Hhf/20))
eq2=vpa(a-b*(k*Q)==Coeff2)
eq3=vpa(a-(c-d)*k==Coeff3)
eq4=vpa(1+a+b+c==7.5)
[a,b,c,d,k]=solve([eq1,eq2,eq3,eq4], [a,b,c,d,k]);
a=double(subs(a));
b=double(subs(b));
c=double(subs(c));
d=double(subs(d));
k=double(subs(k));
a, b, c, d, k, a-b*(k*Q), a-(c-d)*k, 1+a+b+c
The output is below:
a = 1.9953
b = 0.6651
c = 3.8397
d = 1.8444
k = 1
a-b*(k*Q) = 2.2204e-16
a-(c-d)*k = -2.2204e-16
The "a-b*(k*Q)" and "a-(c-d)*k" are very smal numbers but are not zero as requested. These values when multiplied with others are changing the transfer function. Any idea how can be resolved.
Giannis
Respuestas (1)
Dyuman Joshi
el 2 de Mzo. de 2024
And that's why the values are not exactly 0.
If you remove those conversions, the values will, in fact, be 0.
syms a b c d k
Hhf=6;
Q=3;
Coeff2=0;
Coeff3=0;
assume(a,["positive","real"]);
assume(b,["positive","real"]);
assume(c,["positive","real"]);
assume(d,["positive","real"]);
assume(k,["positive","real"]);
eq1=(a==10^(Hhf/20));
eq2=(a-b*(k*Q)==Coeff2);
eq3=(a-(c-d)*k==Coeff3);
eq4=(1+a+b+c==7.5);
[a,b,c,d,k]=solve([eq1,eq2,eq3,eq4], [a,b,c,d,k]);
a, b, c, d, k, a-b*(k*Q), a-(c-d)*k, 1+a+b+c
2 comentarios
Dyuman Joshi
el 2 de Mzo. de 2024
Yes, Control system functionalities in MATLAB, like tf, do not accept symbolic numbers as input (this issue has been raised quite a few times by others as well).
I understand your situation, but unfortunately, you will have to work with the limited precision of double precision numbers, where the values are not exactly zero.
Ver también
Categorías
Más información sobre Equation Solving en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!