
tic
ao=analogoutput('nidaq')
addchannel(ao, 0);
ch0=ao.Channel
frequency  = 1;
amplitude  = 5;
offset     = 0;
dutycycle  = 50;
sampleRate=500;
set(ao,'SampleRate',sampleRate);

%------------------------------------------------------
% 
% numPoints = sampleRate/frequency;
% t = linspace(0,2*pi,numPoints+1);
% t = t(1:end-1);
%    tmp = mod(t,2*pi);
%    w0 = 2*pi*dutycycle/100;
%    nodd = (tmp < w0);
%    y = 2*nodd-1;
% waveData = offset + amplitude*y;

% phase=0;
% numPoints = sampleRate/frequency;
%       t = linspace(0,pi/2,numPoints+1);
%       t = t(1:end-1);
%       waveData = offset + amplitude*sin(t+((phase*pi)/180));

ang=linspace(0,2*pi,6000);
ang = ang(1:end-1);
waveData=5*sin(ang);

pause;
set(ao, 'TriggerType', 'Immediate');
set(ao, 'RepeatOutput', 0.5);
putdata(ao, [waveData]');

start(ao);
disp('pp');
pause;

z=0+offset;
putdata(ao, [z]');
start(ao);

stop(ao);
delete(ao);
toc