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]
Jos (10584) (2019). SLM (https://www.mathworks.com/matlabcentral/fileexchange/10031-slm), MATLAB Central File Exchange. Retrieved .
nice one-line engine... in charming, bloated disguise
in summary, welcome to another member of the family of pedestrians...
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.
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.
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 ...
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?