📄 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 + -