Plotting time-course of matrix entries

조회 수: 1 (최근 30일)
Paul Fishback
Paul Fishback 2013년 10월 15일
편집: Jonathan LeSage 2013년 10월 16일
I have a matrix with real-valued, nonnegative entries. For entry (i,j), I wish to plot a filled circle at the point (i,j) whose color intensity is determined by the magnitude of M(i,j). So for example, if M(2,3) > M(4,8), then a darker dot would appear at (2,3) than at (4,8). I want to draw filled circles as opposed to colored rectangles as one would do using pcolor
EXTRA CREDIT: If the entries of M also change with time, i.e. each entry takes the form M(i,j,t), how could I go about creating an animation that shows the time-course of the various magnitudes. For example, if M(2,3,t) is an increasing function of t, I would want the color intensity of the filled dot at (2,3) to increase.
  댓글 수: 1
Paul Fishback
Paul Fishback 2013년 10월 16일
Okay, I've been able to achieve the first two of my goals by use of scatter plot, with color intensities determined by the matrix entries. So the EXTRA CREDIT question is still open.

댓글을 달려면 로그인하십시오.

채택된 답변

Jonathan LeSage
Jonathan LeSage 2013년 10월 16일
편집: Jonathan LeSage 2013년 10월 16일
Extra credit time! Depending on how you want to ultimately display your results, you have quite a few options. For a quick and dirty approach to plotting your data over time, you can just sequentially update a plot using the imagesc function to depict color intensity of your matrix.
Here is some quick code which illustrates that method:
% Generate a 2x2x10 matrix (x,y,t)
N = 10;
x = reshape(1:N,1,1,10);
dataMat = [rand(1,1,N), 20-x;
x+10, rand(1,1,N)];
colorLimits = [min(dataMat(:)) max(dataMat(:))];
% Step through and plot along the t-axis
for i = 1:N,
imagesc(dataMat(:,:,i),colorLimits);
colorbar
pause(0.5); % Half a second pause between frames
end
To actually animate these results, you can refer to the discussion from another answers question from yesterday:
Finally, as another possibility for displaying your data, you should check out the sliceomatic function that is available on the File Exchange:
Hope this helps to get you started!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by