Specifying a position of a Gaussian fit
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
TTA
am 21 Dez. 2022
Kommentiert: Image Analyst
am 23 Dez. 2022
Please how can I specify where my gaussian should be fitted on a data plot
Below is my matlab code and attahed are my sample plot with the data.
clear; clc;
thisfile = pwd + "\matlabdata.txt\";
Txtdata = load(thisfile);
x = Txtdata(:, 1);
y = Txtdata(:, 2);
inc=~isnan(y);
hgt = find(isnan(y));
gEqn = 'a*exp(-((x-b)/c)^2)+d';
startPoints = [5 0 10 2];
[fj,gof,output] = fit(x,y,gEqn,'Start', startPoints, 'Exclude', hgt);%,'Start', startPoints, 'Exclude', [1 10 25]
plot(fj,x,y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1238487/image.png)
The blue line is anexample of my desired Gaussian.
Its more of shifting a little bit the centre of the Gaussian side ways. I do not know if its possible
Thanks
1 Kommentar
Mathieu NOE
am 22 Dez. 2022
Seems to me you want to "shape" your gaussian curve , not simply shift it
you have to first define which model would better fullfill your task
Akzeptierte Antwort
Image Analyst
am 22 Dez. 2022
Seems like you blew past the posting guidelines. If you have any more questions, then attach 'matlabdata.txt' with the paperclip icon after you read this:
In the meantime see histfit
rng default; % For reproducibility
r = normrnd(10,1,1000,1);
pd = fitdist(r,'Normal')
% Construct a histogram with a normal distribution fit.
plotParameters = histfit(r)
grid on
5 Kommentare
Image Analyst
am 23 Dez. 2022
What makes you think the black curve is better or more accurate than the red curve?
Maybe you should fit a different formula, like a Rayleigh or something. What is the theory behind this experiment? What formula does theory say your data should follow? In the middle range it just seems like total noise - a shotgun blast - like it follows no theoretical distribution whatsoever.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!