How do you display a dynamically changing colormap in the app designer?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dimitar Dyankov
le 3 Mai 2022
Commenté : Dimitar Dyankov
le 7 Mai 2022
Hello, I'm making an app where one window shows a dynamically changing colormap. Specifically, I have a 3D array frame_recording with dimensions 5x10x5000, and I'm running a while loop so that in the n-th iteration, the matrix frame_recording(:,:,n) is displayed in the window in the form of a colormap. I'm using imagesc for this, so something like this:
while(app.numFrame <= app.recording_duration)
imagesc(app.UIAxes, app.frame_recording(:,:,app.numFrame));
colormap(app.UIAxes,'jet');
app.numFrame = app.numFrame + 1;
end
The problem is that there is a large delay when displaying the image, I expect the colormap to change every few milliseconds but instead it takes around 0.3-0.4 seconds. I saw an app made in GUIDE that uses the command set(app.UIAxes, 'CData', app.frame_recording(:,:,app.numFrame) to display it and it works much better, but I get an error that 'CData' is not a valid property name for the set function (I'm using the newer app developer so maybe that's the issue). Is there any other way to make sure the colormap is properly displayed for each iteration in the loop?
0 commentaires
Réponse acceptée
Monica Roberts
le 3 Mai 2022
The 'CData' is on the imagesc object, which is the child of the axes. You could do a few things:
%% Grab the CData from the axes
set(app.UIAxes.Children,'CData',app.frame_recording(:,:,app.numFrame))
Or
%% Give the imagesc a handle to change
im = imagesc(app.UIAxes, app.frame_recording(:,:,app.numFrame));
colormap(app.UIAxes,'jet');
while(app.numFrame <= app.recording_duration)
set(im,'CData', app.frame_recording(:,:,app.numFrame))
drawnow % You might need a drawnow to update the chart
app.numFrame = app.numFrame + 1;
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Blue dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!