Storing data in a real time recording gui using a callback
이전 댓글 표시
Hi,
I have created a GUI to read wavelength data from FBG fibers and reconstruct their shape in real time. To read, I use a TCPIP connection and a callback implemented with a terminatror. This terminator just throws an event when the new-line character is present in the data:
h = animatedline(app.UIAxes);
app.tcpFBG.BytesAvailableFcn = {@readingData,app,h};
app.tcpFBG.BytesAvailableFcnMode = 'Terminator';
app.tcpFBG.Terminator = 'LF';
In the callback "readingData" I read the data from the buffer, reconstruct the shape, store the data and plot the shape of the fibers
function data = readingData(connection,~,app,h)
tic
clearpoints(h)
data = fscanf(connection);
[EngineeredValues,PeakWavelengths,~] = app.fbg.readingData(data);
[shape,curv,curvDir] = app.fbg.reconstruct(EngineeredValues,PeakWavelengths);
app.pushShapeData(shape); %Saving the data in app.shapeData
app.pushCurvData(curv); %Saving the data in app.curvData
app.pushCurvDirData(curvDir); %Saving the data in app.curvDirData
addpoints(h,shape(1,:),shape(2,:),shape(3,:))
toc
end
The functions used to add the read data with data from previous samples is:
function pushShapeData(app,shape)
app.shapeData = cat(3,app.shapeData,shape);
end
function pushCurvData(app,curv)
app.curvData = cat(3,app.curvData,curv);
end
function pushCurvDirData(app,curvDir)
app.curvDirData = cat(3,app.curvDirData,curvDir);
end
I guess this way of storing the data is not efficient, and as the amount of data increases, this operation becomes slower. This problem makes my reconstruction and plotting laggy for long reading times, but as you can see, I don't know the total amount of data to be save because it depends on when the user stops the recording. Is there any efficient way to concatenate these array and store the data efficiently? Thank you in advance.
댓글 수: 3
Mohammad Sami
2020년 2월 1일
Have you tried profiling. Which functions are taking the longest ?
Carlos Fambuena
2020년 2월 1일
Carlos Fambuena
2020년 2월 1일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!