Plotting Matrix Columns with Colorbar

1 回表示 (過去 30 日間)
Moe Szyslak
Moe Szyslak 2020 年 2 月 11 日
回答済み: Navya Seelam 2020 年 2 月 17 日
I have an array that is long in one dimension and short in another, let's say 50 x 5000. Each of the 50 rows is a point in space and each of the 5000 columns is a time. I would like to plot isochrones as so:
X = 50;
T = 5000;
x = 0:X;
t = 0:T;
M = somefun(x,t);
plot(M(:,1234),x,M(2345,:),x,M(3456,:),x,etc...);
However, I would like to plot many irregularly- (logarithmically?) spaced columns and would like to color them with increasing time and provide a corresponding colorbar. I can think of several ways to brute-force this, but I suspect that there is a simple way that I am missing. I envision something that looks like this:
Any help will be greatly appreciated.

回答 (1 件)

Navya Seelam
Navya Seelam 2020 年 2 月 17 日
You can use contour function to plot isochrones as shown below.
x=1:50;
t=1:5000;
M=somefun(x,t) % dimensions of M= 50x5000
t1=[];
x1=[];
for i=1:50
t1=[t1; t];
end
for j=1:5000
x1=[x1 x'];
end
contour(M,x1,t1); % contour levels are chosen automatically
contour(M,x1,t1); % no. of contour levels=100
colorbar;

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by