matlab - plot matrices in desired colors -



matlab - plot matrices in desired colors -

how possible assign color value matrix. illustration have 10by10 matrix values 0 9. afterwards i'd "chess board" 0 = white, 1 = black, 2 = blue...etc...

2nd question if run operations matrices alter each loop , run let's 10 lops (k = 10) - possible create video out of 10 plot pictures i'll getting after each loop. (i'm programming kind of cellular automaton, i'd see how situation changes on time).

thanks

consider example:

%# lets create 10-by-10 matrix, of values in range [0,9] m = fspecial('gaussian',10,2.5); m = (m-min(m(:))) ./ range(m(:)); m = round(m*9); %# prepare video output vid = videowriter('vid.avi'); vidobj.quality = 100; vid.framerate = 5; open(vid); %# display matrix h = imagesc(m); axis square caxis([0 10]) colormap(jet(10)) colorbar %# capture frame writevideo(vid,getframe); %# iterate changing matrix i=1:50 m = rem(m+1,10); %# circular increment set(h, 'cdata',m) %# update displayed matrix writevideo(vid,getframe); %# capture frame drawnow %# forcefulness redisplay end %# close , save video output close(vid);

you can utilize custom colormap, create matrix cmap of size 10-by-3, each row contains rgb values, , pass phone call colormap(cmap)

for matlab versions older r2010b, can utilize avifile function, instead of videowriter:

%# prepare video output vid = avifile('vid.avi', 'fps',5, 'quality',100); %# iterations i=1:50 %# ... %# capture frame vid = addframe(vid, getframe(gcf)); drawnow end %# close , save video output vid = close(vid);

matlab video colors matrix

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -