How do I create a MATLAB MOVIE with a fixed range for the COLORBAR?

29 views (last 30 days)
When I create a MATLAB MOVIE that has figures with varying color ranges, the COLORBAR for each figure is different. Therefore, when I use the MOVIE command, it creates a movie with a COLORBAR that has a varying range.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Sep 2009
To create a MOVIE that has a fixed range for the COLORBAR, you first need to either determine the maximum and minimum color limits (CLIM) of your movie slides or predetermine the color limits (CAXIS). Once you have decided on the color limits, you can then set them using the CAXIS function before you create your MATLAB MOVIE.
Here is an example program that shows how to do this:
[x y] = meshgrid(-40:1:40); % create your movie slides
set(gca, 'nextplot', 'replacechildren');
caxis manual; % allow subsequent plots to use the same color limits
caxis([-1 1]); % set the color axis scaling to your min and max color limits
% now record the movie
k=0.05;
wt=-2:0.1:2;
for j=1:length(wt)
imagf = -x./(x.^2+1);
realf = 1./(x.^2+1);
z = cos(k*y-wt(j)).*imagf+sin(k*y-wt(j)).*realf;
contour(x,y,z);
axis off;
pcolor(x,y,z);
shading interp;
colorbar; % add the colorbar
F(j) = getframe(gcf); % capture the complete figure which includes the colorbar
lighting phong;
end
The above code creates a MATLAB MOVIE that has a fixed range for the COLORBAR.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!