Hello André,
To create dynamic temporal images, use the Axes UI component to plot the images. Then use 'timer' function to execute a function at regular intervals, to update those images.
Follow the below-mentioned steps to create dynamic temporal images using App Designer:
- Add an Axes component to the UI, which will be used to plot the images.
- Create a private property named ‘Timer’.
properties (Access = private)
Timer
end
- Add a ‘startupFcn’ callback for the app. This callback will define the properties of the ‘timer’ object and call the ‘updateImage’ function at regular intervals.
function startupFcn(app)
app.Timer = timer('ExecutionMode', 'fixedRate', 'Period', 0.1, ...
'TimerFcn', @(~,~) updateImage(app));
start(app.Timer);
end
- Add the ‘updateImage’ function as a private method.
function updateImage(app, ~, ~)
imgSize = [100, 100, 3];
newImgData = rand(imgSize);
imagesc(app.UIAxes, newImgData);
axis(app.UIAxes, 'off');
end
- Finally, add the ‘UIFigureCloseRequest’ callback to the app to stop the timer when the app is closed.
function UIFigureCloseRequest(app, event)
stop(app.Timer);
delete(app.Timer);
delete(app)
end
Kindly refer to the following documentation to know more on 'timer' function: