matlab中 solve函数取值进行比较遇到的问题。

Detad=10;
R=10;
x1=15;
y1=495;
x2=15;
y2=512;
syms  x3 y3;
s=solve('(x3-x2)^2+(y3-y2)^2-Detad^2','(x3-x1)^2+(y3-y1)^2-4*R^2','x3,y3');
if s.x3(1)>s.x3(2)
错误提示:
??? Error using ==> sym.sym>notimplemented at 2621
Function 'gt' is not implemented for MuPAD symbolic objects.
Error in ==> sym.sym>sym.gt at 801
notimplemented('gt');
Error in ==> sycp at 86
if s.x3(1)>s.x3(2)
问题描述:
我这个是简单的例子,我主要问题是:已知三角形三边和两个顶点坐标,求第三个顶点坐标。并且是个迭代的过程,迭代过程中三边和其中一个顶点坐标不变,但其中一个顶点不断变化;这样迭代的求多个第三个位置顶点坐标。我在调试中,一直在
solve函数的取值中出问题,因为solve函数求出来的x3,y3都有两个值,我需要比较来求其中的一对值,求的的值用于下一步的迭代计算中

 Accepted Answer

wosarex
wosarex on 25 Nov 2022
因为你的方程是字符串类型,所以,前面定义的常量x1、x2这些都无法传如方程,所以,求得的s的解仍是一个表达式,而非具体的数值,所以在比较大小的时候除了问题。代码改成:
Detad=10;
R=10;
x1=15;
y1=495;
x2=15;
y2=512;
syms  x3 y3;
s=solve((x3-x2)^2+(y3-y2)^2-Detad^2,(x3-x1)^2+(y3-y1)^2-4*R^2);
if s.x3(1)>s.x3(2)
    s.x3(1)
    s.x3(2)
end

More Answers (0)

Tags

Asked:

on 25 Nov 2022

Answered:

on 25 Nov 2022

Community Treasure Hunt

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

Start Hunting!