digital to analog conversion in matlab

Status
Not open for further replies.

krishnan17

Newbie level 4
Joined
Dec 28, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
hi can anyone pls tel me whether there is any in-built function for digital to analog conversion or vice versa in matlab. for ex if my data is like 1 1 1 0 0 0 0 the output should be in a analog form to pass it through the channel in ofdm system... plz help me .
Thanks in advance
 

I understood that you want to do 6-bit DAC. right? If it is true.
Here is my explanation.

Code:
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

if you have a wide width data , You should use for... statement. It would be easy, you know.
Goodluck .
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…