Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Douglas Sondak

Posts: 7
Registered: 12/7/04
plotting inside for loop
Posted: Mar 5, 1997 3:12 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.