How to convert symbolic output which is a polynomial expression into a numeric value while solving three equations with three unknowns?

2 views (last 30 days)
I'm doing my project in image processing where I encountered a problem while solving three equations with three unknowns(this solving of different sets of three equations should be done a no: of times).Unknowns are l1,l2,d.After solving solution appears as polynomial rather than numeric value which is required.I tried using double,vpa etc but can't convert the polynomial to numeric which I require it for plotting in the next stage using l1,l2 only.This is the part of code showing solving three equations.
% part of code where problem encountered
%%%%%%solving equations mathematically
figure,
for i=1:(regions.Count)
syms l1 l2 d
v1=(((l1*x(i))+(l2*y(i))+1)^-1);
v2=(((l1*h(i))+(l2*g(i))+1)^-1);
ua=(v1^2*(x(i)^2+y(i)^2)+v2^2*(h(i)^2+g(i)^2)-(2*v1*v2*(x(i)*h(i)+y(i)*g(i)))-d^2);%%%eqn 1
for j=(i+1):(regions.Count)
phi= (((l1*x(j))+(l2*y(j))+1)^-1);
si=(((l1*h(j))+(l2*g(j))+1)^-1);
ub=(phi^2*(x(j)^2+y(j)^2)+si^2*(h(j)^2+g(j)^2)-(2*phi*si*(x(j)*h(j)+y(j)*g(j)))-d^2);%%%equation 2
for p=(i+2):(regions.Count)
phi= (((l1*x(p))+(l2*y(p))+1)^-1);
si=(((l1*h(p))+(l2*g(p))+1)^-1);
uc=(phi^2*(x(p)^2+y(p)^2)+si^2*(h(p)^2+g(p)^2)-(2*phi*si*(x(p)*h(p)+y(p)*g(p)))-d^2); %%%%eqn 3
S=solve(ua==0,ub==0,uc==0);
plot(S.l1,S.l2)
%numeric::solve(u(i)==0,u(j)==0);
% vpa(S.l1);
%vpa(S.l2);
end
end
end
where x(.),y(.),h(.),g(.) all are elements which can be accessed from a matrix.
These are the warnings appearing:
% warning and errors
Warning: The solutions are parametrized by the symbols:
z1 = RootOf(z^28 -
(7679594735973854647367154893160693751078965589879729149587624747652102995195462064109566975845992276540196691652490088564510070545686755225499613701600376002882418889277488857515110364508634204661109990556248761887757905645602996813834146508684323774478667381814407687196443881925420718968374151325373714697530222075539257913249884701117022195961314642110223806380227408543387251863600133391189837530091095531093532382811127808*z^27)/540030551774220485680352992477622208537031156460313076359678461802207617246795097630461026910203425969809630407228320572661725406696188203488262425450248894441863234920236860162064823297839179005962054381333944963315422908708267810536845548222387268515555469373769358008565800608304319971574438805045722584257306774198655438150951315954086878211271805878297691252436453366920355303562010165487406905746284633341311276441303
+
(35998517358325992706630657008432917857864963002375275189743873589275540452583044814447308845310551179454269695927175116883144633964919130930413620675873462630067790878356634969924109799443073369982477280786518042803751393629225733301195011939104391792355528310497911696651093048883214987090848548035015922295395426053352762814974781924719131969708625825016754098620373307009434844228923737924756573927019957361391937922848736149504*z^26)/540030551774220485680352992477622208537031156460313076359678461802207617246795097630461026910203425969809630407228320572661725406696188203488262425450248894441863234920236860162064823297839179005962054381333944963315422908708267810536845548222387268515555469373769358008565800608304319971574438805045722584257306774198655438150951315954086878211271805878297691252436453366920355303562010165487406905746284633341311276441303
+
(29278945491991206374385838186760117280729078977398383888028105135600055980922618843355747286740992185051229786149665833006068826228232944268946253864463151594019908242474801257637231502727073704792326725651731267366357582696093775518814792411466682681520623743953195129169242378235300809761952505313097950087383074480810680403076573138671124177366825921197172565155458391437378041035696357901492286681144228835414051622741012905984*z^25)/1620091655322661457041058977432866625611093469380939229079035385406622851740385292891383080730610277909428891221684961717985176220088564610464787276350746683325589704760710580486194469893517537017886163144001834889946268726124803431610536644667161805546666408121308074025697401824912959914723316415137167752771920322595966314452853947862260634633815417634893073757309360100761065910686030496462220717238853900023933829323909
-
(3737014713568306876710285030264083318119343107849537944426620851340072265643219515164672127263117958593304732360858560755291145970053916457285949907025735567309715039461339730525249155186955592866429547263999973490127273767500891980995795232777516391922960176415343870149490669948872036340102291755155627885988036864617547843721076361857892236624481417572322025271149766234634102359247069694904214380017098177008745037865649438720*z^24)/43742474693711859340108592390687398891499523673285359185133955405978816996990402908067343179726477503554580062985493966385599757942391244482549256461470160449790922028539185673127250687124973499482926404888049542028549255605369692653484489406013368749759993019275317998693829849272649917697529543208703529324841848710091090490227056592281037135113016276142112991447352722720548779588522823404479959365449055300646213391745543
-
(82530911693488673085571275284122617148041398188301733398813651486126317778889556513178218752286249572751953529480008409979154579543935864221194844877739456272736972827933457048056802116100503927337223905636200897884677051634515550470394138312185380027521423959877121879314727095294719021745319400804649842889327765518603051687402004182162909309336611966542010455770915385663629325511118400274895770566297344211220359750990430208*z^23)/180010183924740161893450997492540736179010385486771025453226153934069205748931699210153675636734475323269876802409440190887241802232062734496087475150082964813954411640078953387354941099279726335320684793777981654438474302902755936845615182740795756171851823124589786002855266869434773323858146268348574194752435591399551812716983771984695626070423935292765897084145484455640118434520670055162468968582094877780437092147101
-
(1527519904922364500751957178252968571718533665515499826424218675808539862224423484733253397651375682712418183237336438005863483752035490102266506937184924850687192547217023359957144505544495314304272828837394988832587248855551986218678739607970787314518172445691909518036111779576711185476578869389495916431747166952275276377656361215161233661154527235645284502245479662163648092102597222290105932796153787412632864796427574837248*z^22)/43742474693711859340108592390687398891499523673285359185133955405978816996990402908067343179726477503554580062985493966385599757942391244482549256461470160449790922028539185673127250687124973499482926404888049542028549255605369692653484489406013368749759993019275317998693829849272649917697529543208703529324841848710091090490227056592281037135113016276142112991447352722720548779588522823404479959365449055300646213391745543
+
(154709191037933311202226440352157664026749091997218572931441623390948720644211727397459714212807735288821849206133911885625228548360061739884265683845279217187794184215795892873022185659005934642802521364078485366259907541647933221070269553109957795606605838300558752108839237032531344711995170230571643160249360638452089890599407814575580189001295034814863328068796986070058970318501002103360536980791575275733278352849451876352*z^21)/43742474693711859340108592390687398891499523673285359185133955405978816996990402908067343179726477503554580062985493966385599757942391244482549256461470160449790922028539185673127250687124973499482926404888049542028549255605369692653484489406013368749759993019275317998693829849272649917697529543208703529324841848710091090490227056592281037135113016276142112991447352722720548779588522823404479959365449055300646213391745543
+
(23941749830392103881417795840278851504426996397528329414103871354162689390971524378074223764924671003887986972788717168719704269354562115819392815635604879395039949726670852959221536314732220843834573465255409894603774823503082695876580447932114336557318503591187511752607722816455325631648741913614672177322089372258822729703529240263571512506231236707128892206416213413565880324935996625006819422833248766134533906902974201856*z^20)/43742474693711859340108592390687398891499523673285359185133955405978816996990402908067343179726477503554580062985493966385599757942391244482549256461470160449790922028539185673127250687124973499482926404888049542028549255605369692653484489406013368749759993019275317998693829849272649917697529543208703529324841848710091090490227056592281037135113016276142112991447352722720548779588522823404479959365449055300646213391745543
+
(18069494039403167581932141168695550620753832492324333448694681967203520306278210483212157871693975300790421456073674548647774206923535902544384931563388547755024727110188821895571602117142658534835518512523492068530267817628448356921348556335423186749778231365824763560384146170484865097731915367878928947708776805095838362149583633185465033018953075738345885951543398792481891412655924893647808864677976651031303486040965120*z^19)/14580824897903953113369530796895799630499841224428453061711318468659605665663467636022447726575492501184860020995164655461866585980797081494183085487156720149930307342846395224375750229041657833160975468296016514009516418535123230884494829802004456249919997673091772666231276616424216639232509847736234509774947282903363696830075685530760345711704338758714037663815784240906849593196174274468159986455149685100215404463915181
-
(14364176587308081990825837324710866747289787404547985708470725717992765675804665605094154205177941416019067316990333793141320470122134824442790448388637382901923218213210299894219341400672579773744445967984126790351904642181934808514403681464700375368492589987895993584622066540684872123011813887747130769134387193177260896754297707570020734899843
> In solve at 180
In SRM_gray at 184
Error using plot
Conversion to double from sym is not possible.
Error in SRM_gray (line 187)
plot(S.l1,S.l2)
%%%the entire code is attached as well.Hope my question is clear

Accepted Answer

Walter Roberson
Walter Roberson on 20 Jun 2015
Try
S = vpasolve(ua==0,ub==0,uc==0);
Also, Remember to add "hold on" as you are only plotting one point at a time.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!