function[A,f,phi]=mcmcprogm(mmax) %Ar = [1,3,5];fr = [0.01,0.03,0.05];phir = [0,0,0]; %sigma = 1; %time = 100; % no. of time steps %actualdatphi(Ar,fr,phir,sigma,time); % to set the starting values loop over i. for i = 1:mmax AMP(i)=1;freq(i)=0.01;phase(i)=0; end h = 6; % starting value of m % start the iterations for k = 1:100000 % A,f and phi will contain the MCMC chains. % set their values at the begginning to the last value of AMP,freq and % phi A(k,:)=AMP;f(k,:)=freq;phi(k,:)=phase; m(k)=h; % setting the kth value of m to be equal to h H = vectamp(h,mmax); for z = 1:mmax [AMP,freq,phase] = mcmcm(A(k,z),f(k,z),phi(k,z),AMP,freq,phase,z,k,H); end % mcmc has been used to find the new values of AMP, freq and phase % use mcmch to find new value of h [h] = mcmch(AMP,freq,phase,h,mmax,H,k); k end save('Am.txt','A','-ascii') save('fm.txt','f','-ascii') save('phim.txt','phi','-ascii') save('m.txt','m','-ascii')