Clear Filters
Clear Filters

Plotting a series of Gaussian...

1 view (last 30 days)
K
K on 27 May 2013
I am trying to make a plot based on a list of values that will all have an intensity of 1. (Eventually I will modify this intensity, but for now, 1 is ok) I would like everywhere except these y values to be zero, and then to apply a Gaussian fit to them with an adjustable width.
I was able to accomplish this when I had just two points using the code:
spectrum = linspace(1100,1199,100);
index1 = spectrum == 1144;
index2 = spectrum == 1164;
index3 = index1 + index2;
Gaussfit = fit(spectrum',index3','gauss5');
plot(spectrum,index3,'.k')
hold on
plot(Gaussfit)
simple, but since I am trying to work with an adjustable number of points, I no longer want to write it this way. So here is the code I am switching to/working on now...
B = 10.4401974;
De = 0.000528;
Levels = 15; %adjustable
x = 0:Levels;
y = B*x.*(x+1)-De*x.^2.*(x+1).^2;
[x',y']; %I use this to gen. a list of my values so I can adjust my linspace function
spectrum = linspace(0,2500);
intensity= 0*y'+1;
plot(spectrum,y','.k')
... ... this does not work so far. Does anyone have a suggestion for a better way of doing this???

Answers (1)

Image Analyst
Image Analyst on 28 May 2013
Edited: Image Analyst on 28 May 2013
Please explain why x and y have 16 values but you're trying to plot y versus spectrum, which is 2501 elements. What values do you want x to take on? Only those from 0 to 15, or at 15 equally spaced places between 0 and 2500? Also explain why you're calculating intensity, which is just zero times y plus 1 so essentially it's 16 ones but then you don't even use it.
Now y is a quadratic equation, so explain in more detail exactly what this means about y: "to apply a Gaussian fit to them with an adjustable width."
  3 Comments
Image Analyst
Image Analyst on 28 May 2013
Please answer the question I asked "What values do you want x to take on? Only those from 0 to 15, or at 15 equally spaced places between 0 and 2500?" It's important. I need to know if you want 16 values, then have lements 17 through 2500 be zero, or if you want "spikes" in your zeros equally spaced at 0, 178, 357, ...2500 - in which case you'd use linspace() to construct the first x.
K
K on 28 May 2013
Alright, I changed the variables because I see it was written a bit counter-intuitive. Hopefully it's bit clearer here, even though the program is not yet working...
B = 10.4401974;
De = 0.000528;
Levels = 15; %adjustable
m = 0:Levels;
n = B*m.*(m+1)-De*m.^2.*(m+1).^2;
['m,n']; %I use this to gen. a list of my values so I can adjust my linspace function
spectrum = linspace(0,2500);
plot(spectrum,n','.k')
So ideally, I'd like peaks at the 16 n-values (but for this number to be adjustable), each fit with an adjustable width Gaussian. So, they won't be equally spaced. Is it possible to do this with linspace()?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!