Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6135893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:32:05+00:00 2026-05-23T17:32:05+00:00

how is it possible to assign certain color to a value from matrix. For

  • 0

how is it possible to assign certain color to a value from matrix.
For example I have a 10by10 matrix with values from 0 to 9.
Afterwards I’d like to get a “chess board” where 0 = white, 1 = black, 2 = blue…etc…

2nd question
if I run some operations where my matrices change with each loop and I run let’s say 10 lops (k = 10) – is it possible to make a video out of this 10 plot pictures I’ll be getting after each loop. (I’m programming some kind of cellular automaton, so I’d like to see how the situation changes over time).

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:32:06+00:00Added an answer on May 23, 2026 at 5:32 pm

    Consider this example:

    %# lets create a 10-by-10 matrix, of values in the 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
    for i=1:50
        M = rem(M+1,10);          %# circular increment
        set(h, 'CData',M)         %# update displayed matrix
    
        writeVideo(vid,getframe); %# capture frame
    
        drawnow                   %# force redisplay
    end
    
    %# close and save video output
    close(vid);
    

    enter image description here

    You can use a custom colormap, simply create a matrix cmap of size 10-by-3, each row contains the RGB values, and pass it to the call colormap(cmap)


    For MATLAB versions older than R2010b, you can use the avifile function, instead of VideoWriter:

    %# prepare video output
    vid = avifile('vid.avi', 'fps',5, 'quality',100);
    
    %# iterations
    for i=1:50
        %# ...
    
        %# capture frame
        vid = addframe(vid, getframe(gcf));
    
        drawnow
    end
    
    %# close and save video output
    vid = close(vid);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out if it's possible to assign two different returned values
Is it possible to assign a global hotkey to a specific feature in an
Is it possible to assign a custom ID to a HTTP session through Servlet
Using Visual Studio 2008 Team Edition, is it possible to assign a shortcut key
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: How do you send email from a Java app using Gmail? How
Is it possible for certain models to be in one database and other models
I want to allocate x number of objects from a certain objective-c class in
Is it possible to assign javascript variable to c# variable in mvc razor view?
Just wonder if it is possible to assign a theme to a page in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.