Filter löschen
Filter löschen

Contourf with loops and making movie from contourf

13 Ansichten (letzte 30 Tage)
M Fahd
M Fahd am 15 Mär. 2018
Kommentiert: KSSV am 20 Mär. 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

Antworten (1)

KSSV
KSSV am 15 Mär. 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 Kommentare
KSSV
KSSV am 20 Mär. 2018
Data is not clear......it got three sheets......can you explain the data?
KSSV
KSSV am 20 Mär. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by