📄 apply.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -