|
datac=;
min_bin=min(datac)+2+30;
max_bin=max(datac)-2-30;
h = hist(datac, min_bin:max_bin); % Histogram
hsum=sum(h);
ch = cumsum(h); % Cumulative histogram
Tlevels = -cos(pi*ch/sum(h));
%Tlevels = ch; % Raised cosine fit
hlin1 = Tlevels(2:end) - Tlevels(1:end-1); % Difference between adjacent bins
hlin = hlin1(3:end-2); % Dump outside bins
hlinsum=sum(hlin);
hlength=(length(hlin));
lsb = sum(hlin) / (length(hlin)); % Find average difference between bins
% to remove gain error
dnl = [0 hlin/lsb-1]; % Remove gain error, center DNL on 0
inl= cumsum(dnl); % INL is integral of DNL
y=datac(1:1446919);
figure;
subplot(2,1,1) % 3 plots: data, histogram, fft
stairs(y)
title('Digital Output Data');
xlabel('Time Index [n]');
ylabel('Magnitude [LSB]');
ylim([0 16383]);
figure;
subplot(2,1,1)
plot(linspace(min_bin, max_bin, length(dnl)), dnl);
title(sprintf('DNL/INL (%g pnt)',length(datac)));
% xlabel('Digital Code [LSB]');
ylabel('DNL [LSB]');
xlim([0 2^14]);
ylim([-1 ceil(max(dnl))]);
subplot(2,1,2)
plot(linspace(min_bin, max_bin, length(dnl)), inl);
% title(sprintf('DNL/INL (%g points)',length(datac)));
xlabel('Digital Code [LSB]');
ylabel('INL [LSB]');
xlim([0 2^14]);
ylim([floor(min(inl)) ceil(max(inl))]);
plot_adc_transfer_curve(14,2,inl,dnl);
把你的数据塞进去就行了
|
|