Let A = $(a_{ij})$ be the matrix with entries
$a_{ij} = i^2+j^2$
A is a $N\times N$ matrix
How can I construct a matrix from this equation?
Let A = $(a_{ij})$ be the matrix with entries
$a_{ij} = i^2+j^2$
A is a $N\times N$ matrix
How can I construct a matrix from this equation?
On
I will address the slightly more general situation where $A\in\mathbb{R}^{M\times N}$, and you can just make $M=N$ if you would like.
[iImg,jImg] = meshgrid( 1:N, 1:M );
A = iImg .* iImg + jImg .* jImg;
Or, for more efficiency,
[iSqImg,jSqImg] = meshgrid( (1:N).^2, (1:M).^2 );
A = iSqImg + jSqImg;
That, or something very like it, should work. Yep. I tried it. Works fine. Even more matlab-y (although personally I'd avoid this kind of thing):