function varargout = gradient(f,varargin)

조회 수: 11 (최근 30일)
Awatif Rashid
Awatif Rashid 2019년 11월 20일
댓글: Jan 2019년 11월 20일
dear all.
excuse me,
Need help in parse_inputs , when I write it I faced error
[f,ndim,loc,rflag] = parse_inputs(f,varargin);
nargoutchk(0,ndim);
Not enough input arguments.
% Loop over each dimension.
varargout = cell(1,ndim);
siz = size(f);
% first dimension
g = zeros(size(f),class(f)); % case of singleton dimension
h = loc{1}(:);
n = siz(1);
% Take forward differences on left and right edges
if n > 1
g(1,:) = (f(2,:) - f(1,:))/(h(2)-h(1));
g(n,:) = (f(n,:) - f(n-1,:))/(h(end)-h(end-1));
end
% Take centered differences on interior points
if n > 2
h = h(3:n) - h(1:n-2);
g(2:n-1,:) = bsxfun(@rdivide,(f(3:n,:)-f(1:n-2,:)),h);
end
varargout{1} = g;
% second dimensions and beyond
if ndim == 2
% special case 2-D matrices to support sparse matrices,
% which lack support for N-D operations including reshape
% and indexing
n = siz(2);
h = reshape(loc{2},1,[]);
g = zeros(size(f),class(f));
% Take forward differences on left and right edges
if n > 1
g(:,1) = (f(:,2) - f(:,1))/(h(2)-h(1));
g(:,n) = (f(:,n) - f(:,n-1))/(h(end)-h(end-1));
end
  댓글 수: 1
Jan
Jan 2019년 11월 20일
What is the relation between the error message and the posted code? Please post the real snippet of the code, which contains the failing command and explain, how you call this function.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by