Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: plotting inside for loop
Replies: 2   Last Post: Mar 6, 1997 11:33 AM

 Messages: [ Previous | Next ]
 Douglas Sondak Posts: 7 Registered: 12/7/04
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!

Doug Sondak
sondak@bu.edu

--------------------------------------------------

for n = 1:2

% run plate

!plate

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]);

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)
colormap(jet)
colorbar

end

Date Subject Author
3/5/97 Douglas Sondak
3/5/97 Damian Packer
3/6/97 Kyle Dippery