function par = makeDependentParameters(par, exclude)
	% Updates parameter struct to ensure dependent parameters are congruent with the associated independent parameters.
	% par: the parameters struct to be updated
	% exlude: an array of strings of parameters you don't want to update. Use with caution, this may introduce fatal errors.

	% define default exclude
	if ~exist("exclude", "var")
		exclude = "";
	end

	% define dependencies
	dependencies = {
		"domainL.Lmax",		@(par) ceil(par.domainL.A * par.domainL.Dg * 1000);
		"domainL.Lmin",		@(par) floor((1 - par.domainL.phiC) * par.domainL.Lmax);
		"domainL.Lrange",	@(par) par.domainL.Lmax - par.domainL.Lmin;
		"domainL.NL",		@(par) ceil(par.domainL.Lrange / par.domainL.dL) + 1;
		"domainL.L",		@(par) linspace(par.domainL.Lmin, par.domainL.Lmax, par.domainL.NL);
		"domainL.dL",		@(par) par.domainL.L(2) - par.domainL.L(1);

		"alpha.fun",		@(par) @(L, tau) par.alpha.beta * tau ./ (par.alpha.beta * tau + L);
		
		"f0.L0",			@(par) par.domainL.Lmax;
		"f0.fun",			@(par) @(tau) par.f0.k * exp(-par.f0.k * tau);
		%"LQ.fun",			@(par) @(Q) par.domainL.Lmax * gammainc(Q / par.LQ.theta, par.LQ.k); 
		"LQ.fun",			@(par) @(Q) par.domainL.Lmin + par.domainL.Lrange * gammainc(Q / par.LQ.theta, par.LQ.k);
		
		"domainT.Nt",		@(par) ceil(par.domainT.D / par.domainT.dt) + 1;
		"domainT.t",		@(par) linspace(0, par.domainT.D, par.domainT.Nt);
		"domainT.dt",		@(par) par.domainT.t(2) - par.domainT.t(1);
		
		"domainTau.Ntau",	@(par) ceil(par.domainTau.tauMax / par.domainT.dt) + 1;
		"domainTau.tau",	@(par) linspace(0, par.domainTau.tauMax, par.domainTau.Ntau);
		"domainTau.dtau",	@(par) par.domainTau.tau(2) - par.domainTau.tau(1);

		"rain.baseflow",	@(par) fzero(@(q) par.LQ.fun(q) - par.domainL.Lmin, [0 1000]);
	};

	% filter out the ones that are excluded
	id = ismember([dependencies{:,1}]', exclude);
	dependencies = dependencies(~id, :);

	% update parameters using dependencies
	for d = 1:height(dependencies)
		names = split(dependencies{d,1}, ".");
		par.(names(1)).(names(2)) = dependencies{d,2}(par);
	end
end