matlab中有关 solve()函数的,问题如下示 15
solve('a*x^2+b*x+c',0),但solve的用法中根本没有如前边命令所示的形式,但为什么还依然能够得出表达式等于0时候的解而不会提示错误呢?话句话说,从效...
solve('a*x^2+b*x+c',0),但solve的用法中根本没有如前边命令所示的形式,但为什么还依然能够得出表达式等于0时候的解而不会提示错误呢?
话句话说,从效果上看,solve('a*x^2+b*x+c',0)等价于solve('a*x^2+b*x+c'),但前者的语法现象在doc solve 中是不存在的,但为什么不会提示错误呢
多谢您的关注与解答,让我们一起找答案,共同提高 展开
话句话说,从效果上看,solve('a*x^2+b*x+c',0)等价于solve('a*x^2+b*x+c'),但前者的语法现象在doc solve 中是不存在的,但为什么不会提示错误呢
多谢您的关注与解答,让我们一起找答案,共同提高 展开
展开全部
看看这个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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询