No BSD License  

Highlights from
submat

Be the first to rate this file! 0 Downloads (last 30 days) File Size: 1.78 KB File ID: #19324

submat

by Garrett Euler

 

25 Mar 2008 (Updated 26 Mar 2008)

Returns the input matrix reduced along indicated dimensions

| Watch this File

File Information
Description

This is a function to aid/simplify access to subsections of a n-d matrix.

Y=SUBMAT(X,DIM,LIST) creates a matrix Y that is the matrix X reduced along dimension DIM to the indices in LIST. If DIM is a list of dimensions, LIST is used to reduce each dimension. LIST also may be any string that can be evaluated to valid indices along DIM such as '1:end-1', '[2 4]', 'X(2,:)', and 'some_other_function'. DIM can not be a string!

Y=SUBMAT(X,DIM1,LIST1,DIM2,LIST2,...) allows for access to multiple dimensions independently.

Acknowledgements
This submission has inspired the following:
submat_noeval, subarray
MATLAB release MATLAB 7.5 (R2007b)
Other requirements Not sure if it works for Matlab pre-7.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
27 Mar 2008 Duane Hanselman

Creates a large string that is passed to EVAL to do the work. Yet another example of why to avoid using EVAL.

31 Mar 2008 Garrett Euler

Thanks for the advice.

File id 19350 was submitted as a non-eval alternative for this function. I prefer the use of eval here, so I will not delete this submission as your comment for the alternative submission suggests. The alternative function will be renamed to clarify the distinction.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrices Garrett Euler 22 Oct 2008 09:55:12
submatrix subset subarray Garrett Euler 22 Oct 2008 09:55:12

Contact us at files@mathworks.com