function [ output_args ] = camb( x )
%CAMB Returns CMB tt spectrum calculated by camb
% x = [ombh2 ombch2 omnuh2 omk hubble w ns];
% load matlab form of params.ini file to pass to camb
load params_strings.mat;
% replace default parameters with parameters from input x vector
% this can be modified to include more parameters, or to tell CAMB
% to produce polarization resuts, etc...
params_strings = regexprep(params_strings, 'ombh2 = 0.022',...
['ombh2 = ' num2str(x(1))]);
params_strings = regexprep(params_strings, 'omch2 = 0.12',...
['omch2 = ' num2str(x(2))]);
params_strings = regexprep(params_strings, 'omnuh2 = 0',...
['omnuh2 = ' num2str(x(3))]);
params_strings = regexprep(params_strings, 'omk = 0',...
['omk = ' num2str(x(4))]);
params_strings = regexprep(params_strings, 'hubble = 70',...
['hubble = ' num2str(x(5))]);
params_strings = regexprep(params_strings, 'w = -1',...
['w = ' num2str(x(6))]);
params_strings = regexprep(params_strings, 'scalar_spectral_index(1) = 1',...
['scalar_spectral_index(1) = 1' num2str(x(7))]);
% output a new params file
% open a file for overwriting
fid = fopen('params_matlab.ini','w');
% write the string out to the file
fprintf(fid,'%s',params_strings);
% close the file
fclose(fid);
% call camb to do calculation
[s, camb_stdout] = system(sprintf('%s %s', 'CAMB/camb', 'params_matlab.ini'));
% get output file
load test_scalCls.dat
% return l locations and cl values
output_args.l = test_scalCls(:,1);
output_args.cl = test_scalCls(:,2);