Jimmy Smith
Jimmy Smith

Reputation: 13

Colored table in Matlab

I am trying to figure out how to generate a colored chart on a matlab, like the one you can find in here on page 9. (You will have to look through it to find what I am referring to - Stackoverflow doesn't allow me to post pictures in the postings just yet.)

A few questions:

  1. I do have the table, but my table is a set of discreet points, not a continuous spectrum. So... can I do it in the first place?

  2. If it IS possible, how would I do it?

(By the way, that table is from combat simulation for Risk - I am doing the combat simulation for Risk II, just for fun.)

Upvotes: 0

Views: 920

Answers (2)

PearsonArtPhoto
PearsonArtPhoto

Reputation: 39718

The type of image you are looking for, as can be seen on Page 9, is a imagesc plot. Here's a simple example, using a double sin function. Done without vectorization for simplicity.

x=0:pi/180:pi;
y=0:pi/180:pi;

output=zeros(length(x),length(y));
for ix=1:length(x)
   for iy=1:length(x)
      output(ix,iy)=sin(x(ix)*2)*cos(y(iy)*4);
   end
end
figure;imagesc(x,y,output)

Upvotes: 1

Bernhard
Bernhard

Reputation: 3694

I think you're looking for the filled contourplot. See also: http://www.mathworks.nl/help/techdoc/ref/contourf.html

Upvotes: 0

Related Questions