Plotting multiple matrices in the same plot, so i can seee how the matrices develop trough time?
3 views (last 30 days)
Show older comments
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
Accepted Answer
Grzegorz Knor
on 7 Oct 2011
My suggestion:
for k=1:size(val,3)
imagesc(val(:,:,k))
colorbar
caxis([18 120])
drawnow
pause(1)
end
2 Comments
More Answers (1)
Dr. Seis
on 7 Oct 2011
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 Comments
Dr. Seis
on 7 Oct 2011
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.
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!