Contourf with loops and making movie from contourf

13 次查看(过去 30 天)
Hello,
I have three data files, namely- X, Y, Z. Each data file is 100(r) x 25(c). I wish to read the data from each files as 20(r) x 25(c) at a time. That is there are 5 time steps. And, finally want to plot as contour (ultimate goal is to make a movie from these 5 steps). Can anybody please suggest me how to do that? I am mostly struggling with the "contourf" portion for iterations (i.e., the steps). Thanks in advance.
~FAHD

回答(1 个)

KSSV
KSSV 2018-3-15
h = figure;
axis tight manual % this ensures that getframe() returns a consistent size
filename = 'test.gif';
for n = 1:1:5
% Draw plot for y = x.^n
[X,Y,Z] = peaks(100) ;
Z = rand(100).*Z ;
contourf(X,Y,Z) ;
drawnow
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if n == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
  4 个评论
KSSV
KSSV 2018-3-20
Data is not clear......it got three sheets......can you explain the data?
KSSV
KSSV 2018-3-20
Fahd commented:
There are three sheets- x-coordinates, y-coordinates and mole fraction. At every time, I want to read 361 rows from all three sheets simultaneously, and plot a contour plot of mole fraction. And, then move on to reading the next 361 rows (362-722) from all three sheets simultaneously, and plot the 2nd contour. As there are 1444 rows, there will be total 4 contour plots, from which I wish to make the GIF/movie. Does it make sense now? Thanks a lot for the helps. Appreciate it.
PS: Don't type comments in answer.....type in comments

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by