How to run two parallel functions,one of them record signals from Data Acquisition System ?

Hello everybody , I'm trying to record signals using Data Acquisition system (DAQ) and to process the received signals, during signals processing the recording process should be ongoing.I wrote code to run recording function and signals processing function in parallel, but I got this error : " Attempt to reference field of non-structure array" at the second line of the recording function. this is my code: S = daq.createSession ('ni') S.DurationInSeconds =1; S.Rate=51200; ch1=S.addAnalogInputChannel('Dev1',0, 'IEPE') ch2=S.addAnalogInputChannel('Dev1',1, 'IEPE') ch3=S.addAnalogInputChannel('Dev1',2, 'IEPE') ch4=S.addAnalogInputChannel('Dev1',3, 'IEPE') Recorded_signals=Recording_code(S); x=1 matlabpool open 2 ; n=1; for i=1:n spmd funList ={@Recording_code,@Processing_code}; dataList={x,Recorded_signals}; labBarrier output= funList{labindex}(dataList{labindex}); end end matlabpool close;
this is the recording function :
function data = Recording_code(S2) data = S2.startForeground();
this is the processing function : function y = Processing_code(data) signal1=data(:,1)-mean(data(:,1)); y=max(signal1) Any help in this regard will be appreciated

Answers (0)

Categories

Find more on Data Acquisition Toolbox in Help Center and File Exchange

Asked:

on 1 May 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!