我已经知道在solve函数第一个参数的公式中,要是有常量;要求出x可用subs
如:
a=1;
subs(solve('a*x-3=0','x'));
但当要求二元函数时,
如:
a=1;
subs(solve('a*x-3+y=0','x-y=2','x','y'));
会出现错误:Conversion to 'sym' from 'struct' is not possible.
因为得到的是一个结构体,而不能转为sym 格式,但因为要解决a的问题,所以需要subs
有没有什么办法可以解决这个问题

 채택된 답변

redosey
redosey 2022년 11월 25일

0 개 추천

多元方程返回的是一个结构体,有两个域,分别对应x、y。不能直接试图替代每个域里的变量。试试下面的:
s = solve('a*x-3+y=0','x-y=2','x','y')
subs([s.x;s.y])

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 测量和特征提取에 대해 자세히 알아보기

태그

질문:

2022년 11월 25일

답변:

2022년 11월 25일

Community Treasure Hunt

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

Start Hunting!