how can curve fitting

조회 수: 4 (최근 30일)
fereshte
fereshte 2014년 5월 17일
편집: fereshte 2014년 6월 29일
hi...i have some scatter points in x-y coordinate.how can curve fitting without using of cftool?i want do it by gussian fitt but in gussian code there are x and y.i domt know how obtain them!
% f = fit(x,y,'gauss8'); % plot(f,x,y); % coeff=fit(x,y,ft);
G is sample matrix with 106*47 in size and meanValue is mean of columns in matrix.result matrix is 1*47 that it is scatter points.
meanValue = mean(G)
thank you
  댓글 수: 1
Image Analyst
Image Analyst 2014년 5월 17일
A screenshot of your data, or attaching your data file, would help us envision what you're talking about.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2014년 5월 17일
Here’s my version of Gauss1 using fminsearch:
% % Single Gaussian Regression
% % Generate x- and y- data:
% x = linspace(0,10); % Generate x-data
% Normal distribution — b(1) = mean, b(2) = std
N = @(b,x) exp(-((x-b(1)).^2)./(2*b(2)^2)) ./ (b(2)*sqrt(2*pi));
% b = [5; 1];
% d1 = N(b,x); % Generate smooth y-data
% d2 = d1 + 0.05*(rand(size(d1))-.5); % Add noise
% % ————— Assign your variables to x and y here —————
x = your independent variable
y = your dependent variable
% % Use ‘fminsearch’ to do regression:
y = d2;
OLS = @(b) sum((N(b,x) - y).^2); % Ordinary Least Squares cost function
opts4 = optimset('MaxFunEvals',50000, 'MaxIter',10000);
B = fminsearch(OLS, rand(2,1))
Nfit = N(B,x); % Calculate estimated fit
The variables you need to have in your workspace are x and y (or assign them to x and y) to use this without modifying the code. The single ‘%’ commented lines are there for illustration. (Uncomment them if you want to see how it works. Remove them if you don’t need them.)
  댓글 수: 27
Image Analyst
Image Analyst 2014년 6월 29일
Please put that "Answer" right here. No need to put a comment here and then say that Star has to look somewhere else down the page for it, especially since it's not really an "Answer" to your original post but a comment to Star.
fereshte
fereshte 2014년 6월 29일
편집: fereshte 2014년 6월 29일
dear Star Strider
i use youre code for my dataset. but it dont work for all images. i change B line in this code respect to locs_Rwave for some images that dont get me true response.but its very difficult.can you help me to get the code that run perfectlly for all images with out any change in B line?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 5월 17일
How about polyfit. I've attached a demo.

카테고리

Help CenterFile Exchange에서 Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by