matlab2016b简化的函数,[求助]Matlab2016b里没有simple函数

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

function [r,h] = simple(s,varargin)

%SIMPLE Search for simplest form of a symbolic expression or matrix.

% SIMPLE(S) tries several different algebraic simplifications of

% S, displays any which shorten the length of S's representation,

% and returns the shortest. S is a SYM. If S is a matrix, the result

% represents the shortest representation of the entire matrix, which is

% not necessarily the shortest representation of each individual element.

%

% [R,HOW] = SIMPLE(S) does not display intermediate simplifications,

% but returns the shortest found, as well as a string describing

% the particular simplification. R is a SYM. HOW is a string.

%

% SIMPLE(S,'IgnoreAnalyticConstraints',VAL) controls the level of

% mathematical rigor to use on the analytical constraints while simplifying

% (branch cuts, division by zero, etc). The options for VAL are TRUE or

% FALSE. Specify TRUE to relax the level of mathematical rigor

% in the rewriting process. The default is FALSE.

%

%

% Examples:

%

% S R How

%

% cos(x)^2+sin(x)^2 1 simplify

% 2*cos(x)^2-sin(x)^2 3*cos(x)^2-1 simplify

% cos(x)^2-sin(x)^2 cos(2*x) simplify

% cos(x)+i*sin(x) exp(i*x) rewrite(exp)

% (x+1)*x*(x-1) x^3-x simplify(100)

% x^3+3*x^2+3*x+1 (x+1)^3 simplify

% cos(3*acos(x)) 4*x^3-3*x simplify(100)

%

% simple(asin(sin(x))) = asin(sin(x))

% simple(asin(sin(x)),'IgnoreAnalyticConstraints',true) = x

%

% See also SYM/SIMPLIFY, SYM/FACTOR, SYM/EXPAND, SYM/COLLECT.

% Copyright 1993-2011 The MathWorks, Inc.

if builtin('numel',s) ~= 1, s = normalizesym(s); end

p = nargout == 0;

[rsym,h] = mupadSimple(s,p,varargin{:});

r = privResolveOutput(rsym, s);

end

function [r,h] = mupadSimple(s,p,varargin)

h = '';

r = s;

x = symvar(s,1);

% parse arguments: Look for options

narg = nargin - 2;

args = varargin;

% default:

options = 'null()';

k = 1;

while k <= size(args, 2)

v = args{k};

if ischar(v) && strcmp(v, 'IgnoreAnalyticConstraints')

if k == size(args, 2);

error(message('symbolic:sym:optRequiresArg', v))

end

value = args{k+1};

if value == true

value = 'TRUE';

elseif value == false

value = 'FALSE';

elseif strcmp(v, 'IgnoreAnalyticConstraints') && isa(value, 'char')

if strcmp(value, 'all')

value = 'TRUE';

elseif strcmp(value, 'none')

value = 'FALSE';

else

error(message('symbolic:sym:badArgForOpt', v))

end

else

error(message('symbolic:sym:badarg', value))

end

options = [options ', ' v '=' value]; %#ok

args(k:k+1) = [];

else

error(message('symbolic:sym:badarg', v))

end

end

% Try the different simplifications.

[r,h] = simpler('simplify',s,r,h,p,options);

[r,h] = simpler('radsimp',s,r,h,p,'null()');

[r,h] = simpler('symobj::simplify',s,r,h,p,options,'100');

[r,h] = simpler('combine',s,r,h,p,options,'sincos');

[r,h] = simpler('combine',s,r,h,p,options,'sinhcosh');

[r,h] = simpler('combine',s,r,h,p,options,'ln');

[r,h] = simpler('factor',s,r,h,p,'null()');

[r,h] = simpler('expand',s,r,h,p,options);

[r,h] = simpler('combine',s,r,h,p,options);

[r,h] = simpler('rewrite',s,r,h,p,'null()','exp');

[r,h] = simpler('rewrite',s,r,h,p,'null()','sincos');

[r,h] = simpler('rewrite',s,r,h,p,'null()','sinhcosh');

[r,h] = simpler('rewrite',s,r,h,p,'null()','tan');

[r,h] = simpler('symobj::mwcos2sin',s,r,h,p,'null()');

if ~isempty(x)

[r,h] = simpler('collect',s,r,h,p,'null()',x);

end

end

function [r,h] = simpler(how,s,r,h,p,options,x)

%SIMPLER Used by SIMPLE to shorten expressions.

% SIMPLER(HOW,S,R,H,P,X) applies method HOW with optional parameter X

% to expression S, prints the result if P is nonzero, compares the

% length of the result with expression R, which was obtained with

% method H, and returns the shortest string and corresponding method.

if nargin < 7

[t,err] = mupadmex('symobj::map',s.s,how,options);

elseif ischar(x)

[t,err] = mupadmex('symobj::map',s.s,how,x,options);

else

[t,err] = mupadmex('symobj::map',s.s,how,x.s,options);

end

if err

return;

end

if nargin == 7

how = [how '(' char(x) ')'];

end

how = strrep(how,'symobj::','');

if p

loose = isequal(get(0,'FormatSpacing'),'loose');

if loose, disp(' '), end

disp([how ':'])

if loose, disp(' '), end

disp(t)

end

cmp = mupadmex('symobj::simpler', t.s, r.s, 0);

if strcmp(cmp,'TRUE')

r = t;

h = how;

end

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值