How to replicate this graph with random peaks?

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!

Antworten (1)

Mathieu NOE
Mathieu NOE am 30 Mai 2022

0 Stimmen

hello
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));
end
surf(xx,yy,z);
colorbar

2 Kommentare

Thanks Mathieu, you saved my problem, I have been looking for such a surface generating code with mulitple peaks for a while...
hello
glad I could be of some help

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022a

Gefragt:

am 27 Mai 2022

Kommentiert:

am 31 Mai 2022

Community Treasure Hunt

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

Start Hunting!

Translated by