📄 nestexample.m
字号:
function fhandle=nestexample(num,den)
%NESTEXAMPLE Example Nested Function.
% NESTEXAMPLE(Num,Den) returns a function handle to a function that can
% be used to evaluate a rational polynomial. Num and Den are vectors
% containing the numerator and denominator polynomial coefficients.
%
% For example, ratpoly=nestexample([1 2],[1 2 3]) returns a function
% handle that facilitates evaluation of the rational polynomial
%
% x + 2
% ------------
% x^2 + 2x + 3
if ~isnumeric(num) || ~isnumeric(den)
error('Num and Den Must be Numeric Vectors.')
end
num=reshape(num,1,[]); % make num into a row vector
den=reshape(den,1,[]); % make den into a row vector
fhandle=@nested_ratpoly;
function out=nested_ratpoly(x)
% Nested function that evaluates a rational polynomial, where the
% numerator and denominator coefficients are shared with the primary
% function workspace
out=polyval(num,x)./polyval(den,x);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -