my solve cant work again

1 回表示 (過去 30 日間)
cehua liu
cehua liu 2023 年 6 月 8 日
コメント済み: cehua liu 2023 年 6 月 8 日
clc;clear;close all;
s_length=0.125;
m=0;n=0;
a=-s_length/4+m%location of a (x=-0.03125,y=0);
b=s_length/4+n %location of b (x= 0.03125,y=0);
x1=5;y1=8; %location of c;
lac85=sqrt((x1-a).^2+(y1).^2);%distance of ac;
lbc85=sqrt((x1-b).^2+(y1).^2);%distance of bc;
dl85=lac85-lbc85;
x2=-4;y2=4; %location of c;
lac44=sqrt((x2-a).^2+(y2).^2);
lbc44=sqrt((x2-b).^2+(y2).^2);
dl44=lac44-lbc44;
syms a1 b1
eq1= sqrt((x1-a1).^2+(y1).^2)-sqrt((x1-b1).^2+(y1).^2)==dl85;%establish an equation using the difference of two distances
eq2= sqrt((x2-a1).^2+(y2).^2)-sqrt((x2-b1).^2+(y2).^2)==dl44;
[a1,b1]=solve(eq1,eq2,a1,b1,'Real', true);
double(a1)
double(b1)
%%%%%%%%%%%%%%%%%%%%%%%%%%the error
警告: Possibly spurious solutions.
警告: Solutions are parameterized by the symbols: x. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
警告: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
错误使用 symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.
Xstr = mupadmex('symobj::double', S.s, 0);

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 6 月 8 日
編集済み: Dyuman Joshi 2023 年 6 月 8 日
You can use vpasolve to solve the equation numerically -
format long
s_length=0.125;
m=0;n=0;
a=-s_length/4+m %location of a (x=-0.03125,y=0);
a =
-0.031250000000000
b=s_length/4+n %location of b (x= 0.03125,y=0);
b =
0.031250000000000
x1=5;y1=8; %location of c;
lac85=sqrt((x1-a).^2+(y1).^2);%distance of ac;
lbc85=sqrt((x1-b).^2+(y1).^2);%distance of bc;
dl85=lac85-lbc85;
x2=-4;y2=4; %location of c;
lac44=sqrt((x2-a).^2+(y2).^2);
lbc44=sqrt((x2-b).^2+(y2).^2);
dl44=lac44-lbc44;
syms a1 b1
eq1= sqrt((x1-a1).^2+(y1).^2)-sqrt((x1-b1).^2+(y1).^2)==dl85;%establish an equation using the difference of two distances
eq2= sqrt((x2-a1).^2+(y2).^2)-sqrt((x2-b1).^2+(y2).^2)==dl44;
%Using vpasolve instead of solve
[a1,b1] = vpasolve(eq1,eq2,a1,b1)
a1 = 
b1 = 
0.031250000000113565406372863339127
double(a1)
ans =
-0.031249999999886
double(b1)
ans =
0.031250000000114
You can also define a1 and b1 to be real from start, in that case, solve() will return a solution via vpasolve() as well, as it is unable to find a symbolic solution.
syms a1 b1 real
  1 件のコメント
cehua liu
cehua liu 2023 年 6 月 8 日
thank you!!!!!!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by