apply.m
来自「hilbert-huang 变换的源码 蛮有用的」· M 代码 · 共 35 行
M
35 行
function varargout = apply(c,func,varargin)
% COMPONENTS/APPLY applies arbitrary functions to a Components strucutre
%
% Usage:
% [any output] = apply(c,func,[any other inputs])
%
% Input:
% c - input Components data
% func - The function handle to apply to the data
% other arguments passed on to 'func'.
% Output:
% all Components structures, each holding the output of 'func' for each
% input component in sequence
%
% Notes:
% Only 1 and 2 outputs are implemented.
% This function is mainly intended to help make wrappers for "plain"
% functions to allow them to work on Components structures. As such, it is
% most useful as a model for programmers.
% Kenneth C. Arnold (for NASA GSFC), 2004-08-06
nc = get(c,'nc');
varargout{1} = c;
if nargout == 1
for i=1:nc
varargout{1}.d(i).c = feval(func,c.d(i).c,varargin{:});
end
elseif nargout == 2
varargout{2} = c;
for i=1:nc
[varargout{1}.d(i).c, varargout{2}.d(i).c] = feval(func,c.d(i).c,varargin{:});
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?