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
0 件のコメント
回答 (1 件)
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
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 Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!