?? polyn2sym.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 + -