How to replicate this graph with random peaks?

3 views (last 30 days)
Maxine Genove
Maxine Genove on 27 May 2022
Commented: Mathieu NOE on 31 May 2022
I need help replicating this graph that is perfect for the project I am working on right now.
One characteristic that is especially difficult for me to grasp is the continuous surface the peaks are attached to. Is there an equation or function that can get me to this point?
Edit: Changing the sign of Z in the peaks function seems to have done the job. However, I'd like to make it so that I can change the location and amplitude of these peaks. Is there a way I can modify the peaks function equation to do so?
I'm not exactly sure how to do this, so any advice is much appreciated. Thank you!

Answers (1)

Mathieu NOE
Mathieu NOE on 30 May 2022
see little demo below , based on random data (up to you to specify x, y centers , sigmas and z amplitudes )
here I generated 10 peaks with random positions , sigmas and peak amplitude
% dummy random data
x = (0:1:100);
y = (0:1:100);
xc = max(x)*rand(10,1); % x center
yc = max(y)*rand(10,1); % y center
sigmax = 2+7*rand(10,1); % x sigma
sigmay = 3+5*rand(10,1); % y sigma
A = rand(10,1); % peak amplitude
nb_peaks = numel(xc);
[xx,yy] = meshgrid(x,y);
z = 0;
for ck = 1:nb_peaks
z = z + A(ck)*exp(-(xx-xc(ck)).^2/(2*sigmax(ck)^2)-(yy-yc(ck)).^2/(2*sigmay(ck)^2));

Sign in to comment.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!