有大佬吗?想要求解六​元二次方程组,但是总​是有问题啊 。

有个问题,怎么把代码编写到帖子里啊
function sol= myfun(P1,P2,P3)
syms x xb xc y yb yc eq1 eq2 eq3 eq4 eq5 eq6 real
eq1=x^2+y^2-P1^2;
eq2=(xb-5)^2+yb^2-P2^2;
eq3=xc^2+(yc-6)^2-P3^2;
eq4=(xc-xb)^2+(yc-yb)^2-3^2;
eq5=(x-xc)^2+(y-yc)^2-(3*2^(1/2))^2;
eq6=(x-xb)^2+(y-yb)^2-3^2;
sol=vpasolve(eq1,eq2,eq3,eq4,eq5,eq6);
end

 Réponse acceptée

0 votes

function sol= myfun(P1,P2,P3)
syms x xb xc y yb yc real
eq1 = x^2+y^2-P1^2 == 0;
eq2 = (xb-5)^2+yb^2-P2^2 == 0;
eq3 = xc^2+(yc-6)^2-P3^2 == 0;
eq4 = (xc-xb)^2+(yc-yb)^2-3^2 == 0;
eq5 = (x-xc)^2+(y-yc)^2-(3*2^(1/2))^2 == 0;
eq6 = (x-xb)^2+(y-yb)^2-3^2 == 0;
sol = vpasolve([eq1,eq2,eq3,eq4,eq5,eq6],[x xb xc y yb yc]);
end
clear; clc; close all;
P1 = 5; P2 = 5; P3 = 3;
sol = myfun(P1,P2,P3);
disp( [sol.x sol.xb sol.xc sol.y sol.yb sol.yc] )
[ 2.1651168366834558530151579208329, 0.44054161217134919760879296231526, -2.0142170918562008234172945066687, 4.5069134763726966356500634270848, 2.0521547723451466146239759581008, 3.7767299968572532700303409166184]
[ 4.4817500653990297385549779609795, 5.724478736892678966958239234846, 2.9939796160271128101561844886024, 2.2167355167668949182932738482495, 4.9472346376324610750953285944931, 6.1899633091261103034985898683596]
[ 4.5718301753324558609302522482768, 3.0162868277591425626018934025198, 0.45108022909688077539162373299101, 2.0244428487659526668420248766202, 4.589649447428214454052294546149, 3.034106099854901155723935700392]
[ -1.3783796305976990305694763121869, 0.8753568865682464318704581279913, 2.8554254993169849986502814951123, 4.8062531762229661763429350247873, 2.8261845634742276095631116576663, 5.0799210806401730720030460978446]
[ 4.3713490808224342852543186928004, 1.66803257070615438550477470361, 2.9688322655603379803960090142916, 2.4272015189499323661034771935793, 3.7280012138041159609947115042608, 6.4313177239203958607442554934512]
[ -0.91470871683433754097095685396404, 1.9224397112218673810465430316042, 2.8974211454954669743421623877926, 4.9156187772596116672588949197502, 3.9406373429860120739632755635618, 6.77778577104221699598077544913]

Plus de réponses (0)

Catégories

En savoir plus sur MATLABMobile 基础知识 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!