Appending different size arrays each itteration in app desinger
3 次查看(过去 30 天)
显示 更早的评论
I have an program which gets data from an oscilloscope and finds peaks in the signal, these peaks are stored in an private property called HoogtePulsen. And in one of the callbacks i want to put these peaks in an histogram.
function TimerFcn_Callback2(app,~,~)
%TimerFcn_Callback Timer callback function which executes periodically
% When LivePlotTimer is running this function does periodic waveform live plot updates
y = app.HoogtePulsen.Value * 100;
histogram(app.UIAxes_2,y,100,"BinLimits",463:464);
drawnow
end
This works fine, but i want to append the y value in an array every itteration of this callback. So i get an array of every peak found in all the measured signals of the oscilloscope. What is the easiest way to accomplish this in app desinger?
0 个评论
采纳的回答
Tim Koopman
2020-7-6
You could perhaps initialize a new property as an empty array and then append to this array with every iteration:
properties (Access = public)
yourArray = [];
end
This section of code should be somewhere in the beginning of your code, before the callbacks that handle component events.
You then append to this array in your TimerFcn_Callback2 callback:
app.yourArray(end+1,1) = y;
3 个评论
Tim Koopman
2020-7-7
Not totally sure without seeign the error message. My best guess is it is because app.AllePieken does not have a Value property.
Try using
data = app.AllePieken;
instead.
更多回答(1 个)
Geoff Hayes
2020-7-6
remco - you could perhaps create a member variable for your App and then update that variable with the y on each call to the timer callback.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Instrument Connection and Communication 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!