Hi,
Does anyone know how do I obtain a figure like the one in attachment?
I have x axis and y axis data corresponding to the top (or bottom) of the blue sticks, so that if I plot it in Matlab it gives me just a point at the end of the stick. What I would like to do is to draw that continuous line which would represent the spectrum and giving it a definite peak width (the same for all the peaks is ok); if also the blue stick can be added it would be great.
I am not very good with Matlab, so I hope you understand what I mean and someone can solve my problem.
Thanks

 Réponse acceptée

Rik
Rik le 7 Fév 2019
You can do something like this:
%set some mu,height,sd pairs
%(replace with your actual data)
mu_list=[1200 1350 1500 1550 1600];
height_list=[300 100 100 200 75];
sd_list=[20 20 100 20 40];
%define the x-scale
x=linspace(1100,1700,1000);
%define a scalable gaussian
G_fun=@(x,mu,sd) 1/sqrt(2*pi*sd^2)*exp(-(x-mu).^2/(2*sd^2));
G_fun_scaled=@(x,mu,sd,scale) scale*sqrt(2*pi*sd^2)*G_fun(x,mu,sd);
%loop over the gaussians to get the sum
figure(1),clf(1)
y=zeros(size(x));
for n=1:numel(mu_list)
[mu,sd,scale]=deal(mu_list(n),sd_list(n),height_list(n));
y=y+G_fun_scaled(x,mu,sd,scale);
plot([mu mu],[0 scale],'b'),hold on
end
plot(x,y,'k')

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by