Plotting multiple matrices in the same plot, so i can seee how the matrices develop trough time?
3 次查看(过去 30 天)
显示 更早的评论
Sorry for the horrible english, but i don't know how to explain it otherwise.
I want to plot these matrices:
val(:,:,1) =
18 18 18 18 18
18 18 18 18 18
18 18 18 18 18
18 18 18 18 18
18 18 18 18 18
val(:,:,2) =
18 18 18 18 120
18 18 18 18 120
18 18 18 18 120
18 18 18 18 120
120 120 120 120 120
val(:,:,3) =
18.0000 18.0000 18.0000 18.9139 120.0000
18.0000 18.0000 18.0000 18.9139 120.0000
18.0000 18.0000 18.0000 18.9139 120.0000
19.0662 19.0662 19.0662 19.9802 120.0000
120.0000 120.0000 120.0000 120.0000 120.0000
val(:,:,4) =
18.0000 18.0000 18.0082 19.8115 120.0000
18.0000 18.0000 18.0082 19.8115 120.0000
18.0119 18.0119 18.0201 19.8234 120.0000
20.1118 20.1118 20.1200 21.9041 120.0000
120.0000 120.0000 120.0000 120.0000 120.0000
On the same graph, so i can see (with colors) how the matrices develop trough time. The matrix itself shows me the spacial location. The numbers on the matrix shows the temperature, and the first matrix is time = 1, the next time = 2, then time = 3 and last time=4.
Thanks.. :D
采纳的回答
Grzegorz Knor
2011-10-7
My suggestion:
for k=1:size(val,3)
imagesc(val(:,:,k))
colorbar
caxis([18 120])
drawnow
pause(1)
end
更多回答(1 个)
Dr. Seis
2011-10-7
If you want to make a movie to use outside of Matlab, then look up "getframe" and something like "movie2avi" in the Navigation Help. For example:
for k=1:size(val,3)
handle = imagesc(val(:,:,k))
colorbar
caxis([18 120])
save_frame(k) = getframe(handle);
end
movie2avi(save_frame,'MyMovie.avi')
You can adjust the rate that frames are displayed per second (see Help for more info).
2 个评论
Dr. Seis
2011-10-7
Check out "interp2" in the Navigation Help. Instead of calculating and storing a bigger NxN matrix for each time stamp, you might be able to interpolate between the calculated points and use this more dense version for display purposes only.
For N = 5:
[X,Y] = meshgrid(1:5);
[X1,Y1]=meshgrid(1:0.1:5);
handle = imagesc(interp2(X,Y,val(:,:,k),X1,Y1));
Put the definition of X,Y,X1, and Y1 before the for loop... since these do not need to be redefined after each loop iteration.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!