Plotting a series of Gaussian...
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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???
0 comentarios
Respuestas (1)
Image Analyst
el 28 de Mayo de 2013
Editada: Image Analyst
el 28 de Mayo de 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 comentarios
Image Analyst
el 28 de Mayo de 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.
Ver también
Categorías
Más información sobre Matrix Indexing 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!