求教:matlab 2015b 中没有simple函数你是怎么解决的? 20

 我来答
qingningleyun
2016-05-06 · TA获得超过5856个赞
知道大有可为答主
回答量:2991
采纳率:30%
帮助的人:3311万
展开全部

% 拷贝一个

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<AGROW>
        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
意法半导体(中国)投资有限公司
2023-06-12 广告
单片机,即单片微控制器,也称为单片微型计算机,是将中央处理器(CPU)、存储器(ROM,RAM)、输入/输出接口和其他功能部件集成在一块 在一个小块的集成电路上,从而实现对整个电路或系统的数字式控制。单片机不是完成某一个逻辑功能的芯片,而是... 点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式