%function x = symspace(arg1,n,arg2) % % Title: SYMmetric linearly SPACEd vector % % For two input arguments: % % Purpose: Generates a row vector of linearly spaced points % between -xmax and xmax with 0 at the center. % i.e., of the form: % % x = [-xmax .... 0 .... +xmax] (if n is odd) % x = [-xmax+delta .... 0 .... +xmax] (if n is even) % % Input: arg1 = xmax = |range(x)| % n = number of points to generate % % For three input arguments: % % Purpose: Generates a row vector of linearly spaced points % between x0-dx and x0+dx with x0 at the center. % i.e., of the form: % % x = [x0-dx .... x0 .... x0+dx] (if n is odd) % x = [x0-dx+delta .... x0 .... x0+dx] (if n is even) % % Input: arg1 = dx % n = number of points to generate % arg2 = x0 % % Notes: Similar in concept to MATLAB's linspace.m % function x = symspace(arg1,n,arg2) % Defaults if(nargin<2),n=64;end; % Make sure n is even nn = n - odd(n); npts = nn/2+1; if(nargin<=2), xmax = arg1; xa = linspace(-xmax,0,npts); xb = linspace(0,xmax,npts); x = [xa,xb(2:length(xb))]; x = x(1:length(x)-even(n)); elseif(nargin==3), x0 = arg2; dx = arg1; xmin = x0 - dx; xmax = x0 + dx; xa = linspace(xmin,x0,npts); xb = linspace(x0,xmax,npts); x = [xa,xb(2:length(xb))]; x = x(1+even(n):length(x)); end