Appdesigner performance reduces drastically when acquiring data in loop

1 回表示 (過去 30 日間)
Ajai Singh
Ajai Singh 2021 年 12 月 7 日
コメント済み: Geoff Hayes 2021 年 12 月 17 日
Hello everyone,
I am using Appdesigner to build a GUI to acquire data from a NI device, The idea is to acquire EMG data for 3 seconds in background and wrtie the data to a csv file after the data acquistion is complete. And this process will be repeated 50 times. The process is smooth for upto 5 iterations and after that , matlab takes a lot of time to execute the same lines of code it did before and the screen freezes in the mean time.
Is there anyway to overcome this problem? or are there some "best practices" for appdesigner.
Or should i use GUIDE?
Thank you.
  3 件のコメント
Ajai Singh
Ajai Singh 2021 年 12 月 15 日
Thank Chris, I think I am already doing that . Given below is the code :
for i = 1:50
d = daq('ni');
AvailableDevice = daqlist;
Ch1 = addinput(d,AvailableDevice.DeviceID,'ai18','Voltage');
d.Rate = 2000; % number of samples per second
d.ScansAvailableFcn = @(obj,evt)plotMyData(obj,evt,i,EMGPlotHndl,OPDir,FName);
start(d,'continuous'); % Uncomment this when running on labs computeR
pause(RandTimeMatrix(i)/1000) % Random Pause Time
InitTime4DAQ = tic;
InitTime4Parti = tic;
waitforbuttonpress;
BRTMat(i,1) = toc(InitTime4Parti);
FinalTIme4DAQ = toc(InitTime4DAQ);
BRTMatDeltaT(i,1) = FinalTIme4DAQ - BRTMat(i,1);
disp(FinalTIme4DAQ)
pause(0.1)
stop(d)
end
Geoff Hayes
Geoff Hayes 2021 年 12 月 17 日
@Ajai Singh - consider creating the daq object outside of the loop rather than on each iteration. Or perhaps comment on your above implementation and why you have chosen to do the above (wait for the button press, etc.).

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Acquisition Toolbox Supported Hardware についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by