
plotting inside for loop
Posted:
Mar 5, 1997 3:12 PM


I am trying to set up a matlab demonstration which works as follows. First, a fortran code is run, writing two data files. The files are then read into matlab, and the results are plotted. This works fine if I carry out this procedure once, but I need to do it within a "for" loop. When I try the loop, a figure appears after the first iteration, but no plot is drawn. The plot does not appear until the final (in this case second) iteration has completed. Does anyone know how I can get the plot to draw every iteration? The .m file is shown below. By the way, this is a simplified version of my final goal  one step at a time! Thanks for any help you can offer.
Doug Sondak sondak@bu.edu

for n = 1:2
% run plate
!plate
% read grid
fidg = fopen('grid.d','rt'); nx = fscanf(fidg,'%i',1); ny = fscanf(fidg,'%i',1); x = fscanf(fidg,'%f',[nx,ny]); y = fscanf(fidg,'%f',[nx,ny]);
% read solution
fids = fopen('plate.d','rt'); idum = fscanf(fids,'%i',1); idum = fscanf(fids,'%i',1); dum = fscanf(fids,'%f',1); dum = fscanf(fids,'%f',1); dum = fscanf(fids,'%f',1); dum = fscanf(fids,'%f',1); phi = fscanf(fids,'%f',[nx,ny]);
% plot
view(2) surface(x,y,phi) shading interp colormap(jet) colorbar
end

