matlab中有关 solve()函数的,问题如下示
发布网友
发布时间:2024-10-03 10:36
我来回答
共2个回答
热心网友
时间:2024-11-29 04:58
看看这个solve对于方程的处理 你就知道了 最好单步运行一下 内部直接把你的这个0丢掉了~
function [eqns,vars] = getEqns(varargin)
eqns = [];
vars = [];
for k = 1:nargin
v = varargin{k};
vc = char(v);
if ~isempty(eqns) && all(isstrprop(vc,'alphanum') ...
| vc == '_' | vc == ',' | vc == ' ')
if isa(v,'sym') && any(strcmp(vc,{'beta','gamma','psi','theta','zeta','D','E','O','Ei','Si','Ci','I'}))
vc = [vc 'MLVar']; %#ok<AGROW>
end
vc(vc == ' ') = [];
vars = [vars ',' vc]; %#ok<AGROW>
elseif isa(v,'sym')
eqns = [eqns v(:).']; %#ok<AGROW>
else
[t,stat] = mupadmex(vc,0);
if stat
error('symbolic:solve:errmsg1', ...
''' %s '' is not a valid expression or equation.',v)
end
if ~isempty(t)
% use a set syntax to preserve the list items without
% causing the string to be parsed as MATLAB arrays [a b]
t = sym(['{' vc '}']);
eqns = [eqns t(:).']; %#ok<AGROW>
end
end
end
vars = ['[' vars ']'];
if vars(2)==','
vars(2)=' ';
end
热心网友
时间:2024-11-29 04:58
印象中solve是可以求解方程组的根的
solve('x+y-1','x-y-3')