No BSD License  

Highlights from
IND2SUBVECT: Multiple subscript vector from linear index.

Be the first to rate this file! 20 Downloads (last 30 days) File Size: 1.68 KB File ID: #5476

IND2SUBVECT: Multiple subscript vector from linear index.

by David Fass

 

12 Jul 2004 (Updated 16 Jul 2004)

A perversion of IND2SUB that returns a vector of N indices rather than N individual variables.

| Watch this File

File Information
Description

See IND2SUB for the basic idea. IND2SUBVECT makes a one-line change to IND2SUB so as to return a vector of N indices rather than returning N individual variables. (This makes the function easier to use when the size of the matrix being indexed is not known in advance.) I hope MathWorks will forgive me for adapting their function and/or include this tweak in a future version of IND2SUB.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
04 Oct 2004 Mukhtar Ullah

I would like to suggest the following as a compact and faster alternative:

function v = ind2subv(siz,ndx)
[out{1:length(siz)}] = ind2sub(siz,ndx);
v = cell2mat(out);

29 Apr 2011 Jaap

Thanks.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrices David Fass 22 Oct 2008 07:27:31
subscript David Fass 22 Oct 2008 07:27:31
convert David Fass 22 Oct 2008 07:27:31
linear David Fass 22 Oct 2008 07:27:31
index David Fass 22 Oct 2008 07:27:31
vector David Fass 22 Oct 2008 07:27:31

Contact us at files@mathworks.com