在MATLAB中,可以使用solve
函数来解方程。solve
函数的一般形式为solve(equations, variables)
,其中equations
是方程的集合,variables
是方程中的未知数。
例如,要解方程x^2 - 3*x + 2 = 0
,可以使用如下代码:
syms x
equation = x^2 - 3*x + 2 == 0;
sol = solve(equation, x);
输出结果为:
sol =
1
2
这表示方程的解是x=1和x=2。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:matlab解方程组的方法有哪些