% hfk_pp.m
% convert the data record from hex to signed 16 bit
% integers
% Copyright 2008 The MathWorks, Inc.
num_pts = 800;
compare_with_simulation_results = 0; % set to zero if you only want the data in the ML workspace
plot_measured_data_only = 0;
fid = fopen('C:\Work\ecwf\hand_code\myec.mch','rt');
for k = 1:num_pts
four_hex_chars = fgetl(fid);
sout_dspic(k) = hex2dec(four_hex_chars);
if (sout_dspic(k) >= 32768)
sout_dspic(k) = sout_dspic(k) - 65536;
end;
end;
if (plot_measured_data_only == 1)
figure;plot(sout_dspic);
end
if (compare_with_simulation_results == 1)
sout_sl = logsout.Echo_Canceller.sout_linear.data;
figure;plot(1:num_pts,sout_sl(1:num_pts)*2^14,'r',1:num_pts,sout_dspic,'b');grid;
title('simulated EC output overlaid with dsPIC EC output');
legend('SL','dsPIC');
figure;plot(1:num_pts,sout_sl(1:num_pts)*2^14-sout_dspic','b');grid;
title('difference between SL and dsPIC');
%sout_f = 20*log10(abs(fft(sout_dspic,512)));
%figure;plot([0:8000/512:8000-8000/512],sout_f);grid;
end
fclose(fid);
disp('done');