中南大学cadcam技术及应用试题及答案内容摘要:

,39。 X must be a vector.39。 )。 end if length(x) ~= n if isvector(y) error(39。 MATLAB:interp1:YInvalidNumRows39。 , ... 39。 X and Y must be of the same length.39。 ) else error(39。 MATLAB:interp1:YInvalidNumRows39。 , ... 39。 LENGTH(X) and SIZE(Y,1) must be the same.39。 )。 end end % Prefer column vectors for x xCol = x(:)。 else xCol = (1:n)39。 end % Process XI in INTERP1(Y,XI,...) and INTERP1(X,Y,XI,...) % Avoid syntax PP = INTERP1(X,Y,METHOD,39。 pp39。 ) if ~ppOutput xi = varargin{2+xOffset}。 siz_xi = size(xi)。 % xi may be an ND array, but flatten it to a column vector xiCol xiCol = xi(:)。 % The size of the output YI if isvector(y) % Y is a vector so size(YI) == size(XI) siz_yi = siz_xi。 else if isvector(xi) % Y is not a vector but XI is siz_yi = [length(xi) ds]。 else % Both Y and XI are nonvectors siz_yi = [siz_xi ds]。 end end end if xOffset amp。 amp。 ~isreal(x) error(39。 MATLAB:interp1:ComplexX39。 ,39。 X should be a real vector.39。 ) end if ~ppOutput amp。 amp。 ~isreal(xi) error(39。 MATLAB:interp1:ComplexInterpPts39。 , ... 39。 The interpolation points XI should be real.39。 ) end % Error check for NaN values in X and Y % check for NaN39。 s if xOffset amp。 amp。 (any(isnan(xCol))) error(39。 MATLAB:interp1:NaNinX39。 ,39。 NaN is not an appropriate value for X.39。 )。 end % NANS are allowed as a value for F(X), since a function may be undefined % for a given value. if any(isnan(yMat(:))) warning(39。 MATLAB:interp1:NaNinY39。 , ... [39。 NaN found in Y, interpolation at undefined values \n\t39。 ,... 39。 will result in undefined values.39。 ])。 end if (n 2) if ppOutput || ~isempty(xi) error(39。 MATLAB:interp1:NotEnoughPts39。 , ... 39。 There should be at least two data points.39。 ) else yi = zeros(siz_yi,superiorfloat(x,y,xi))。 varargout{1} = yi。 return end end % Process METHOD in % PP = INTERP1(X,Y,METHOD,39。 pp39。 ) % YI = INTERP1(Y,XI,METHOD,...) % YI = INTERP1(X,Y,XI,METHOD,...) % including explicit specification of the default by an empty input. if ppOutput if isempty(varargin{3}) method = 39。 linear39。 else method = varargin{3}。 end else if nargin = 3+xOffset amp。 amp。 ~isempty(varargin{3+xOffset}) method = varargin{3+xOffset}。 else method = 39。 linear39。 end end % The v5 option, 39。 *method39。 , asserts that x is equally spaced. eqsp = (method(1) == 39。 *39。 )。 if eqsp method(1) = []。 end % INTERP1([X,]Y,XI,METHOD,39。 extrap39。 ) and INTERP1([X,]Y,Xi,METHOD,EXTRAPVAL) if ~ppOutput if nargin = 4+xOffset extrapval = varargin{4+xOffset}。 else switch method(1) case {39。 s39。 ,39。 p39。 ,39。 c39。 } extrapval = 39。 extrap39。 otherwise extrapval = NaN。 end end end % Start the algorithm % We now have column vector xCol, column vector or 2D matrix yMat and % column vector xiCol. if xOffset if ~eqsp h = diff(xCol)。 eqsp = (norm(diff(h),Inf) = eps(norm(xCol,Inf)))。 if any(~isfinite(xC。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。