Contourf with loops and making movie from contourf
    조회 수: 9 (최근 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!

