function [f,g,h,sp]=dloudApfiltA_com(values)
% Generates the file loudApfiltA_com.m
%
% [F,G,H]=DLOUDAPFILTA_COM(VALUES) generates the file loudApfiltA_com.m used in simulations of 
% the device defined by dloudApfiltA_lit and parameters in strucuture VALUES
%
% [F,G,H]=DLOUDAPFILTA_COM uses the default parameter values defined by dloudApfiltA_lit


%   CBVK Toolbox
%   JHMG, PMSB 2016


if nargin==0
    [f,g,h,x,names,values,sp]=dloudApfiltA_lit;
else
    [f,g,h,x,names,vd,sp]=dloudApfiltA_lit;
end

% Substitute numerical parameters
for i=1:length(names)
    eval([names{i} '= values.' names{i} ';']);
end

f=subs(f);
g=subs(g);
h=subs(h);

filef = fopen('loudApfiltA_com.m','w');

fprintf(filef,'%sDiff equation of loudspeaker + post filter \n','%');
fprintf(filef,'%sf(x) \n','%');
fprintf(filef,'mydx(1)= %s ;\n',char(f(1)));
fprintf(filef,'mydx(2)= %s ;\n',char(f(2)));
fprintf(filef,'mydx(3)= %s ;\n',char(f(3)));
fprintf(filef,'%sg(x) \n','%');
fprintf(filef,'mydx(3)= mydx(3)+uf*(%s);\n',char(g(3)));
fprintf(filef,'mydx(4)= %s ;\n',char(f(4)));
fprintf(filef,'mydx(5)= %s ;\n',char(f(5)));
fprintf(filef,'mydx(6)= %s ;\n',char(f(6)));
fprintf(filef,'mydx(7)= %s ;\n',char(f(7)));

fclose(filef);





