Centre X-Y data so that the highest value of Ys is at the centre of X. And then average the curve to fit into gaussian.

조회 수: 1 (최근 30일)
Hello, I have X-Y data of a curves (one coloumn for X and 4 columns for Y). I want to centre the Y data so that the highest value of Y gets to the centre of X. Right now the curves are haphazurd and I ant to make to symmetrical. I also want to fit the average of the curves into a gaussian profile.
Any help is greatly appreciated.
  댓글 수: 1
Matt J
Matt J 2022년 11월 11일
이동: Matt J 2022년 11월 11일
I think it would be better just to fit a gaussian (e.g. using fit) to each pair (X,Y(:,i)). Then the fitted mean in each column would tell you were the maximum should be.

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

채택된 답변

Matt J
Matt J 2022년 11월 11일
편집: Matt J 2022년 11월 11일
Using gaussfitn from this FEX download,
you can do a simultaneous fit of all the columns:
[X,Y{1:4}]=readvars('X-Y.xlsx'); Y=cell2mat(Y); Y=Y(:);
t0=fminsearch( @(t)objfunc(t,X,Y) ,zeros(1,4) );
[~,dX,p]=objfunc(t0,X,Y);
f=@(x) p{1} + p{2}*exp( -0.5 * (x-p{3}).^2/p{4} ); %fitted Gaussian
[dX,is]=sort(dX);
Y=Y(is);
plot(dX,Y,'x',dX,f(dX)); shg
function [fval,dX,params]=objfunc(t,X,Y)
dX=X-t(:).'; dX=dX(:);
[params,fval]=gaussfitn(dX,Y,[],[],[],'Display','off');
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by