Gaussian envelope on the diagonal of a matrix
2 次查看(过去 30 天)
显示 更早的评论
I want to create a matrix that on its diagonal appears a Gaussian envelope. In other words, I want the Gaussian of some width sigma to be peaked at the diagonal of the matrix (say 1 is the peak value of the Gaussian I want to use, so I'm looking to have 1 on all of the diagonal elements of the matrix and smaller values on the off diagonal elements).
Any ideas on how to do this?
2 个评论
回答(1 个)
Bjorn Gustavsson
2020-9-26
Something like this:
[x,y] = meshgrid(0:32);
M = exp(-(x-y).^2/4^2);
imagesc(x(1,:),y(:,1),M)
Adjust width as you see fit.
HTH
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!