Pity that eval is forbidden - I had quite an elegant solution using it.
Set a diagonal
Generate a vector like 1,2,2,3,3,3,4,4,4,4
Magic is simple (for beginners)
Convert a substructure reference string into a valid definition structure for subsref and subsasgn
Power supply: 230V to 115V
Operate on matrices of unequal, yet similar, size
Wrap a vector, but insert NaN's at the wrap-positions.
Bleed non-zeros to the right
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office