matrixfunction

版本 1.1.0.0 (10.3 KB) 作者: Pierce Brady
summary
719.0 次下载
更新时间 2009/3/3

查看许可证

functions that allow functions to operate on the rows and coloums of matrixs. similiar to arrayfun and bsxfun.
Saves time having to implement for loops or figuring out how to vectorise your code

% matrixfun
% Y = matrixfun(hFunction,A,B,Dim)
%
% Invokes hFunction on the columns of matrices A and B.
% hFunction is a function handle that accepts two vectors.
% hFunction is invoked aCols*bCols times.
% Y is a cell matrix of size([aCols bCols]).
% If Dim is 2, hFunction operates on the rows of matrices A and B.
%
% Example
% A = [1 1 1; 2 2 2; 3 3 3]
% Y = matrixfun(@(X,Y)sum(X-Y),A,A);
% Y = [0] [0] [0]
% [0] [0] [0]
% [0] [0] [0]
%
% Y = matrixfun(@(X,Y)sum(X-Y),A,A,2); % = matrixfun(@(X,Y)sum(X-Y),A.',A.')
% Y = [0] [-3] [-6]
% [3] [ 0] [-3]
% [6] [ 3] [ 0]
%

引用格式

Pierce Brady (2024). matrixfunction (https://www.mathworks.com/matlabcentral/fileexchange/23146-matrixfunction), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2007b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Arithmetic Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.1.0.0

added 3 functions to handle single matrices

1.0.0.0