Académique Documents
Professionnel Documents
Culture Documents
% This class uses the Markov Chain Monte Carlo Method to fit curves to
% noisy data by finding minima using variable jump sizes.
properties
Tvector
Sigma
JumpSigma
Data
FuncH
Model
GuessConstant
NumberOfJumps
ModelFound
FigGUI
res
end
methods
function obj = MCMC(obj)
hold on
subplot(2,1,1); % Plot for the second quadrant.
plot(obj.Tvector,obj.ModelFound); % Plots the fitted curve.
for nn=2:obj.NumberOfJumps % Iterates through the number of jumps for test points.
end
FoundTheta=mean(Chain); % Parameters found = average of accepted values.
obj.ModelFound=obj.Model(FoundTheta,obj.Tvector); % Fills resulting values into object property.
plot(obj.Tvector,obj.ModelFound) % Plots the fitted curve.
legend('Data','Initial Guesss','Fit') % Legend for the plots.
end
function delete(obj)
end
function gui(obj)
% Graphical User Interface function for the class to have
% modularity for jump size, the number of jumps, and the
% initial guess.
Z=findall(0,'Tag','MCMCGUI') % Checks for an empty figure.
if ~isempty(Z);return;end
% Setup UI CONTROLS----------------------------------------------
TextBoxA = uicontrol('Style','edit','String','Number of Jumps',... % First Text Box (editable).
'Position',[100 300 50 50]);
ALabel = uicontrol('Style','text','String','Number of Jumps',... % Label for the first text box.
'Position',[0 300 50 50]);
TextBoxB = uicontrol('Style','edit','String','Jump Size',... % Second text box for jump size (editable).
'Position',[100 250 50 50]);
BLabel = uicontrol('Style','text','String','Jump Size',... % Label for the second text box.
'Position',[0 250 50 50]);
function runMCMC(~,~)
gui2property() % Callback for button.
obj.MCMC() % Runs MCMC function.
property2gui()
end
function property2gui()
TextBoxA.String=num2str(obj.NumberOfJumps); % Writes object property for the number of jumps to
the first uicontrol.
TextBoxB.String=num2str(obj.JumpSigma); % Writes object property for the jump size to the second
uicontrol.
TextBoxC.String=num2str(obj.GuessConstant); % Writes object property for the initial guess to the third
uicontrol.
TextBoxD.String=num2str(obj.Sigma); % Writes object property for the noisiness of the data to the
fourth uicontrol.
end
function gui2property()
obj.NumberOfJumps=str2double(TextBoxA.String); % Value for first object property.
obj.JumpSigma=str2double(TextBoxB.String); % Value for second object property.
obj.GuessConstant=str2double(TextBoxC.String); % Value for third object property.
obj.Sigma=str2double(TextBoxD.String); % Value for fourth object property.
end
end
end
end