How to set background image for changing plot without using hold on/off?

3 views (last 30 days)
Hey Guys!
I have simulated the heat transfer in a Turbine Injector and save the corresponding temperatures for many timesteps in a matrix. I now want to plot this matrix succesively for different timesteps to show the evolution of the heat. However, behind this plot I want to show a picture of the 2D Drawing of the Injector so that you can see where actually the heat is flowing to.
The code shown here works but obviously in this case the drawing of the injector gets replaced by the plotting of the matrix. If I use hold on/off however, the drawing of the injector stays but all the imagesc-plots are overlaid, which I also don't want.
Any ideas?
Thanks so much!
% hold on?
imshow(drawing_2D_injector);
for i = 1:num %timesteps
for j = 1:39
a = coords{j}; % in coords the coordinates of the flow areas are saved
A(a) = B(i,j); % in B the temperatures are saved
end
colormap(jet);
imagesc(A,'AlphaData',0.7);
drawnow
pause(0.1)
end

Accepted Answer

DGM
DGM on 24 Nov 2021
Edited: DGM on 24 Nov 2021
I suppose this is one way. I'm sure there are others.
imshow('peppers.png');
hold on % use hold
for i = 1:5 % placeholder value
A = imresize(randn(20,20),[384 512]); % test overlay
colormap(jet);
if i ~= 1; delete(himg); end % but delete any prior overlays
himg = imagesc(A,'AlphaData',0.7);
drawnow
pause(0.1)
end

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!