% MSE curve for filters + loudspeaker A, Volterra filter model up to P=4
% memory N=100, 100 realizations of input, 25 scales of output
%
%   CBVK Toolbox
%   JHMG, PMSB 2016

clear

% Order
P=4;
% Memory
N=100;
% Sampling frequency
Fs=5000;

%----------------------------------------------------------------
load inputs_r100.mat inputs

% Simulation output generated with ode133 by
% sim_AfiltA_r100_s25.m. The output is
% saved since execution time is very long
load outputs_AfiltA_r100_s25.mat outputs scales

% Literal linear-analytic model
[f,g,h,x,names,values]=dloudAfiltA_lit;      

% State vector dimension
m=length(x);

% Kernels (diagonal form)
kernels = voltkernels(f,g,h,x,names,values,P,N,1/Fs,0,0,1,1);

% Simulations for mse curves
reali=(1:100);
[mse,times] = genmse(inputs,outputs,scales,kernels,'VF',P,reali,[],1);

plot(20*log10(scales),20*log10(mse))


%save mseAfiltA_P4_N100_r100_s25 scales mse
