cheby.m

来自「提供一个直接搜索算法程序」· M 代码 · 共 42 行

M
42
字号
function [C,X,Y]=cheby(fun,n,a,b)%Input   - fun is the string function to be approximated%        - N is the degree of the Chebyshev interpolating polynomial%        - a is the left endpoint%        - b is the right endpoint%Output  - C is the coefficient list for the polynomial%        - X contains the abscissas%        - Y contains the ordinates%  NUMERICAL METHODS: Matlab Programs% (c) 2004 by John H. Mathews and Kurtis D. Fink%  Complementary Software to accompany the textbook:%  NUMERICAL METHODS: Using Matlab, Fourth Edition%  ISBN: 0-13-065248-2%  Prentice-Hall Pub. Inc.%  One Lake Street%  Upper Saddle River, NJ 07458if nargin==2, a=-1;b=1;endd=pi/(2*n+2);C=zeros(1,n+1);for k=1:n+1   X(k)=cos((2*k-1)*d);endX=(b-a)*X/2+(a+b)/2;x=X;Y=eval(fun);for k =1:n+1   z=(2*k-1)*d;   for j=1:n+1      C(j)=C(j)+Y(k)*cos((j-1)*z);   endendC=2*C/(n+1);C(1)=C(1)/2;   

⌨️ 快捷键说明

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