Info

This question is closed. Reopen it to edit or answer.

Problem in surface fitting: Input parameters are not the same as output parameters

1 view (last 30 days)
Hi everyone,
I am trying to carry out surface fitting of a custom function.
% These are the inputs for my surface:
[X,Y] = meshgrid(1:50,1:50);
sigma_value = 2;
sigma_value2 = 2;
mu_value = 4 ;
angle_wall = pi*1/2 ;
yCoord_WheretheSimCentres = mu_value ;
xCoord_WheretheSimCentres = 50/2;
AmplitudeofWallSurvFun = (1/20);
% This is my surface:
IntensityOfOneRow = (((1/2).*(erfc((Y-yCoord_WheretheSimCentres)./((1.414).*sigma_value))))).*((1./sqrt(2*pi*(sigma_value2).^2)).*(1000).*(AmplitudeofWallSurvFun).*exp((-(-(X - xCoord_WheretheSimCentres).*sin(angle_wall) + (Y - yCoord_WheretheSimCentres).*cos(angle_wall)).^2)./(2.*(sigma_value2.^2))));
I would like to fit the surface using the custom function below, and get the input parameters that I put in, as outputs:
modelFun = fittype( @(p1,p2,p3,p4,X,Y)(((1/2).*(erfc((Y-p1)./((1.414).*p2))))).*((1./sqrt(2*pi*(p3).^2)).*(1000).*(AmplitudeofWallSurvFun).*exp((-(-(X - p1).*sin(p4) + (Y - p1).*cos(p4)).^2)./(2.*(p3.^2)))),'independent',{'X','Y'},'dependent',{'IntensityOfOneRow'} );
[X,Y] = meshgrid(1:size(IntensityOfOneRow,2),1:size(IntensityOfOneRow,1));
[XOut, YOut, ZOut] = prepareSurfaceData(X,Y,IntensityOfOneRow) ;
% This 'prepares' my surface, so that it can be fit.
Fit_Func = fit([XOut,YOut],ZOut,modelFun) ;
% This is the actual fitting step.
disp(Fit_Func)
This procedure, for some reason, does not give my the same input and output parameters.
Could someone please tell me where I am going wrong? I would greatly appreciate it.
Thank you very much,
Aarat
  1 Comment
Samarth Shah
Samarth Shah on 15 Jul 2016
  • Can you tell me about which parameters are you talking about?
Do you mean that when you call prepareSurfaceData, the X, Y, & IntensityOfOneRow are different than XOut, YOut & ZOut respectively?
  • Or, do you mean that every time you call the fit function, you get varying coefficients?
You can also contact Technical Support at MathWorks, if you are looking for a quicker resolution.

Answers (0)

Community Treasure Hunt

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

Start Hunting!