How to solve two-equations two-unknowns expecting a unique positive integer value for each variable?
Mostra commenti meno recenti
Hello Commuinty,
I hope you are doing well.
I've got two sets of equations, same orders but with different coeffiecients as following. m and n are -16.135571 and -130.15315, respectively and I haven't found any relationship between them yet. I want to solve this system so as ending up a unique positive integer number for each variable. Is this possible?
I've written the following code to solve it but at the end of the day what I end up with is just a set of complex numbers and I don't know that if possible answers are involved or not. Under what circumistances I could reach that point? do I need to use any predictor or what?? what if I find a correlation between the inputs or outputs??
Any suggestion would be appreciated. Thank you in advance...
m=-16.135571;
n=-130.15315;
% First equation coefficients
p00 = -16.17;
p10 = 0.0579;
p01 = 0.2456;
p20 = 0.00202;
p11 = 0.000276;
p02 = 0.1334;
p30 = -1.112e-05;
p21 = -0.002938;
p12 = 0.1167;
p03 = -1.882;
% Second equation coefficients
p00p = -131.1;
p10p = 0.2864;
p01p = 3.502;
p20p = -0.005359;
p11p = -1.929;
p02p = 8.532;
p30p = -4.325e-05;
p21p = 0.01226;
p12p = 0.7535;
p03p = -17.02;
syms x y
a=1;
b=90;
c=0.1;
d=0.5;
t=p00 + p10.*x + p01.*y + p20*x.^2 + p11.*x.*y + p02.*y.^2 + p30.*x.^3 + p21.*x.^2.*y + p12.*x.*y.^2 + p03.*y.^3==m;
g=p00p + p10p.*x + p01p.*y + p20p.*x.^2 + p11p.*x.*y + p02p.*y.^2 + p30p.*x.^3 + p21p.*x.^2.*y + p12p.*x.*y.^2 + p03p.*y.^3==n;
Eqns=[t,g];
S=solve(Eqns,[x y])
x=S.x
y=S.y
minmax = @(x,a,b) max(min(x,a),b); % restricts input X between a and b
minmax = @(y,c,d) max(min(y,c),d); % restricts input X between a and b
2 Commenti
Sara Boznik
il 27 Giu 2021
Code looks fine, maybe you send the equations you have?
Mehdi Alipour M.
il 28 Giu 2021
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Systems of Nonlinear Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





