⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get_submatrix.m

📁 小波压缩编码平台软件包
💻 M
字号:
function [S,Sind] = get_submatrix(X,Ssiz,Soff)
%[S,Sind] = get_submatrix(X,Ssiz,Soff)
%Version: 1.00, Date: 2005/01/12, author: Nikola Sprljan
%Extracts submatrix from a multidimensional matrix
%
%Input: 
% X - matrix of n dimensions
% Ssiz - submatrix size to be extracted
% Soff - submatrix starts at this offset
%
%Output:
% S - submatrix
% Sind - indices of the extracted submatrix in the original submatrix
%
%Note:
% To use the extracted indices, use: X(Sind{:})
%
%Example: 
% Suppose I have an N-dimensional matrix X, and I want to extract the 
% submatrix of which each dimension is of half the size than in X (with 
% the offset at the first element of X). Then, it would be called:
% S = get_submatrix(X,ceil(size(X)/2));

if isvector(X) n = 1;
else n = ndims(X);end;
if (nargin < 3) Soff = ones(n,1);end; %sets the default offset
Sind = repmat({':'},n,1);
for i = 1:n
    Sind{i} = Soff(i):(Soff(i) + Ssiz(i) - 1);
end;
S = X(Sind{:});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -