Working backwards to find parameters that produced best fit model and Contour plot annotation.

2 views (last 30 days)
Im comparing some field data to a model and I'm trying to find the values for two variables (dke and theta) that produce the best fitting model, i.e. lowest RMS (root mean square) value. I know what the best RMS is but I don't know how to work backwards to find the best fitting values for dke and theta.
I also wish to annotate a contour plot for RMS over the range of dke and theta tested. Is there a way I can annotate the plot with the best RMS value with an arrow pointing to its point? Hope someone can help. Cheers.
% Define the variables x = rawdata(:,1); I = -64.*pi/180; h = 1; A = 45.*pi/180; T = 55000; d = 5;
% Calculate dT
for i = 1:31
for j = 1:46
dke = 0.002:0.0001:0.005;
theta = 45.*pi/180:2.*pi/180:135.*pi/180;
a = 2.*atan(tan(I)./cos(A))-theta(j);
AMP = 2.*dke(i).*T.*((sin(I)./(sin(atan(tan(I)./cos(A)))))^2).*sin(theta(j));
dT_calc = AMP.*(sin(a).*(atan((x + d) ./ h) - atan((x - d) ./ h)) - ...
(cos(a)./2).*log(((x + d).^2 + h.^2)./((x - d).^2 + h.^2)));
% RMS
% Comparing the quality of fit between the observed and calculated data
n = 201; % Number of values
RMS(i,j) = sqrt((1./n).*(sum((dT_obs - dT_calc).^2)));
end
end
Best_RMS = min(RMS(:));

Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!