?? 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 + -