Azzera filtri
Azzera filtri

Contourf with loops and making movie from contourf

13 visualizzazioni (ultimi 30 giorni)
M Fahd
M Fahd il 15 Mar 2018
Commentato: KSSV il 20 Mar 2018
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

Risposte (1)

KSSV
KSSV il 15 Mar 2018
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 Commenti
KSSV
KSSV il 20 Mar 2018
Data is not clear......it got three sheets......can you explain the data?
KSSV
KSSV il 20 Mar 2018
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

Accedi per commentare.

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by