I want to create random bumps on a flat surface
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daniel Gray
el 17 de Jul. de 2017
Comentada: AMERA ANJUM
el 23 de Mayo de 2020
I have a 300x300 zeros matrix and I would like to create random bumps on the surface on random heights. To be more detailed, imagine circles of ones on the surface, I would like to (rather than those) have bumps on the surface.
Almost like 3D Guassian bumps on the surface.
Any help would be appreciated.
0 comentarios
Respuesta aceptada
Grzegorz Knor
el 17 de Jul. de 2017
M = zeros(300,300); % initial matrix
N = 3; % number of bumps
sigma = 3;% std (width) of Gauss
maxAmplitude = 5; % maximum height
[x,y] = meshgrid(1:size(M,1),1:size(M,2));
for k=1:N
% random location of bumps
xc = randi(size(M,1));
yc = randi(size(M,2));
% Gauss function
exponent = ((x-xc).^2 + (y-yc).^2)./(2*sigma^2);
amplitude = rand()*maxAmplitude;
% add Gauss to the matrix M
M = M + amplitude*exp(-exponent);
end
surf(M)
shading interp
2 comentarios
AMERA ANJUM
el 23 de Mayo de 2020
Daniel Sir
On generation of random bumps at random locations of random amplitudes on the flat surface, do shrinkage of the flat surface area from the edges can be seen. So that over all area on bumping and debumping remains to be same. Please do reply
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!