I am using matlab to use an AI and an AO at the same time in a loop. I basically get the signal by PCI 6229 and send back the signal to the system by PXI-6133. The code below is the code I would like to use it for this reason. The code is working fine but it is so slow. I would like to use it in a close to the real time but its far away from being real time.
May I ask you to please guide me to how to speed up my code?
AI = analoginput('nidaq','Dev1');
chan = addchannel(AI,0);
duration = 0.0005; %0.5ms second acquisition
ActualRate = get(AI,'SampleRate');
blocksize = get(AI,'SamplesPerTrigger');
Fs = ActualRate;
AO = analogoutput('nidaq','Dev4');
chan_o = addchannel(AO,0);
rampR=zeros(500,1); %% ramp rise
rampF=zeros(500,1); %% ramp fall
AI.ManualTriggerHwOn = 'Trigger';
rampR (10*i+1:10*i+10) = previous_pos+a(slope)*[1:10];
data = getdata(AI);
[f,mag] = daqdocfft(data,Fs,blocksize);