?? trs.m
字號:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% thresholds calculation from ideal and mismatched %
% (both random and linear gradient) %
% resistive binary string %
% code by Fabrizio Conso, university of pavia, student %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
function [v,v_err]=trs(nbit,vref)
vref_err=vref*0.1*randn(1);
for i=1:nbit %calculation of resistance values
R(1)=1;
R1(1)=1+0.1*0.5*randn(1)+0.01*(i); % ideal DAC
R(i+1) =2^(i-1);
R1(i+1)=2^(i-1)+0.1*0.5*randn(1)+0.01*(i); % mismatched DAC
end
for j=1:nbit %calculation of tension values
v(j) =vref*sum(R(1:j))/sum(R);
v_err(j)=vref_err*sum(R1(1:j))/sum(R1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
v=v;
if nargout > 1
v_err=v_err;
end
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -