How to handle large variables in workspace
Mostrar comentarios más antiguos
I have a code shown below which reads data from data aquisition object and updates variable signal and update time plot and specturm plot. the problem is that, as measurement goes along(which means very large size of variable signal), plot update speed and UIApp(created by app designer) performance get significantly slow. threshold timing depends on sampling frequency. In case of 51200Hz, I found it is approximately 40sec. but I need to measure data while 120sec... so how can I handle this large size of data generated in workspace?
n = ceil(app.daqDevice.Rate/10);
signal = [];
% start measurement
start(app.daqDevice,"continuous")
pause(0.1)
while(1)
% check measurement end condition
if app.Button_2.Value == 1
stop(app.daqDevice)
app.Button.Value = 0;
save(fullfile(app.SaveFolderPath,...
str2double(app.TrialNumber_Value.Text)+...
"_"+app.SpeedList.Value+".mat"),...
'signal')
return;
end
% read data form DataAquisition Obj
data = read(app.daqDevice,n);
% update measured value
signal = [signal; data];
% update time plot
plot(app.Timeplot,data.Time, data.Variables)
ylim(app.Timeplot,[-1,1])
% update spectrum plot
[pxx,f] = pwelch(data.Variables,512,256,1024,32000);
plot(app.PSDplot,f, 10*log10(pxx))
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Acquisition Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!