data = [1 1 1 0 0 0];
function analog=myDAC(digital)
% digital input must be 6 bit width in this case(MSB first).
% and suppose your analog output's maximum voltage is 5V it would be like that
% digital(0) ~ 2.5V = (maximum_voltage/(2^1))
% digital(1) ~ 1.25V = (maximum_voltage/(2^2))
% digital(2) ~ 0.625V = (maximum_voltage/(2^3))
% digital(3) ~ 0.3125V = (maximum_voltage/(2^4))
% digital(4) ~ 0.15625V = (maximum_voltage/(2^5))
% digital(5) ~ 0.078125V = (maximum_voltage/(2^6))
%then:
analog = digital(0)*2.5 + digital(1)*1.25 + digital(2)*0.625 + digital(3)* 0.3125 + digital(4)*0.15625 + digital(5)*0.078125;
end