⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polyn2sym.m

📁 多项式拟合的MATLAB工具。只要具有以下几个函数 POLYFITN - A general n-dimensional polynomial fitting tool POLYVALN - An
💻 M
字号:
function s = polyn2sym(polyn)% polyn2sympoly: convert a regression polynomial from polyfitn into its symbolic toolbox form% usage: sp = polyn2sym(polyn)%% arguments: (input)%  polyn - a structure as returned from polyfitn%% arguments: (output)%  s - A symbolic toolbox object%% After conversion into a symbolic toolbox form, any symbolic operations are% now possible on the polynomial.% % Requirement: The symbolic toolbox, as supplied by the MathWorks.% http://www.mathworks.com/products/symbolic/functionlist.html%% See also: polyvaln, polyfit, polyval, sym%% Author: John D'Errico% Release: 3.0% Release date: 8/23/06if exist('sym','file')~=2  error 'Please obtain the symbolic toolbox from the MathWorks'end% initialize the returned argument as symbolics = sym(0);% Unpack the fields of polyn for useVarlist = polyn.VarNames;Expon = polyn.ModelTerms;Coef = polyn.Coefficients;% how many terms?nterms = length(Coef);% Was the list of variable names empty?% If so, then generate a list of names of my own.nvars = size(polyn.ModelTerms,2);if isempty(Varlist)  Varlist={};  for i = 1:nvars    Varlist{i} = ['X',num2str(i)];  endend% make the vars symbolicfor i = 1:nvars  Varlist{i} = sym(Varlist{i});end% build the polynomialfor i = 1:nterms  term = sym(Coef(i));  for j = 1:nvars    term = term*Varlist{j}^Expon(i,j);  end    % accumulate into s  s = s+term;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -