File Exchange

image thumbnail

SLM

version 2.0 (1.62 KB) by Jos (10584)
special linear matrix

0 Downloads

Updated 18 Feb 2019

View License

SLM creates a special matrix in which each element is the same as its linear index.
I know, it's quite simple, but I find such a matrix is often useful during algorithm development. It has exactly the same calling index as <ones>, <rand> etc.

SLM(2,3) => [1 3 5 ; 2 4 6]

Cite As

Jos (10584) (2019). SLM (https://www.mathworks.com/matlabcentral/fileexchange/10031-slm), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

jin hanyang

woxiazaibuxialaia

urs (us) schwarz

nice one-line engine... in charming, bloated disguise
in summary, welcome to another member of the family of pedestrians...
us

Duane Hanselman

I meant to hit the N/A button, but the 1 button is right next to it and now I can't undo it. You code is very well documented and written. Excelling at those two things makes it a very good submission.

Jiro Doke

I like the use of consistent syntax as the other built-in matlab functions. Clever how you made the error message to be consistent as well. And you used 'mfilename' so that people can rename the function without affecting the functionality.

Jos van der Geest

Duane, I know it's as simple as that. You can always rename it (as I often do with FEX files).
I like that its calling syntax is like ones and gives the same errors when called erroneously. Moreover, you don't need to calculate N, as in reshape ...
Also I do not see why you give this a one-star rating, besides its simpleness ...

Duane Hanselman

Why not just use the standard one-liner:
reshape(1:N,i,j,...) or reshape(1:N,[i j ...])
This is very easy to understand visually, perhaps more so that remembering what SLM stands for?

Updates

2.0

modernised

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux