不接受deadline之后提交的作业.
所有的程序作业应当放在名为nspde_yourID的文件夹下,并压缩成一个文件提交.
每次程序作业提供一个driver运行所有的程序, 生成所有的图片.
除driver外,所有的程序放到private文件夹下.
driver请命名为:homework1_dirver_yourID.m, homework2_dirver_yourID.m ….
图片命名为figx_x, 如Fig 2.2 命名为fig2_2.
所有的图片请保存在nspde_yourID的figure文件夹下.
程序作业的文件结构请参考下面的示例.
| | --- nspde_yourID | |___________ figure | | |____________ fig2_2.fig | | |____________ fig2_2.eps | | . | | . | | | |___________ private | | |_____________ xx.m | | |_____________ xxx.m | | . | | . | | | |___________ homework1_dirver_yourID.m | |___________ homework2_driver_yourID.m | . . . . .
注释应当使用英文.
函数名和文件名必须相同.
控制、循环语句应当使用缩进.
尽量将代码内容控制在前80列之内.
通常情况下,一行代码应当只包含一个可执行语句.
二元运算符,如 ==, ~=, &&, ||, 前后应该加一个空格. 更多的规范,请参考 Chebfun coding style conventions.
function [x,w,v] = chebpts(n, varargin) %CHEBPTS Compute the second kind chebyshev points. % [X,W,V] = CHEBPTS(N) retuns N Chebyshev points of the second kind in [-1, 1]. % X is the second kind Chebshev points, W is the weights of Clenshaw-Curtis % quadrature, and V is the barycentric weights corresponding to the Chebyshev % points X. % % [X,W,V] = CHEBPTS(N,[a,b]) retuns N Chebyshev points of the second kind in % [a, b]. % % Example: % % [x, w] = chebpts(10, [-2,2]); % w*x.^2 % quadrature of x^2 in [-2,2] % % This programe is adapted from Chebfun/chebtech2.chebpts, http://www.chebfun.org/ if n == 1 x = 0; w = 2; v = 1; else % Chebyshev points: m = n - 1; x = sin(pi*(-m:2:m)/(2*m)).'; % (Use of sine enforces symmetry.) % quadratrue weights c = 2./[1, 1-(2:2:(m)).^2]; % Exact integrals of T_k (even) c = [c, c(floor(n/2):-1:2)]; % Mirror for DCT via FFT w = ifft(c); % Interior weights w([1,n]) = w(1)/2; % Boundary weights % barycentric interpolate weights v = [0.5;ones(n-1,1)]; % Note v(1) is positive. v(2:2:end) = -1; v(end) = .5*v(end); end if nargin == 2 [x, w] = rescale(x, w, varargin{1}); end end function [x, w] = rescale(x, w, dom) %RESCALE Rescale the quadrature points and weights. a = dom(1); b = dom(2); w = .5*w*(b-a); x = .5*(a+b) + .5*(b-a).*x; end