Results 1 to 3 of 3

Math Help - [SOLVED] MATLAB disp() function doesn't cut it...

  1. #1
    Newbie
    Joined
    Oct 2009
    Posts
    20

    [SOLVED] MATLAB disp() function doesn't cut it...

    Hi,

    I've been working on a simulation for a little while now. I'm to the point where I'm trying to run the simulation for a longer time period (I mean physical time represented in the simulation) than before, and I'd like to be able to track the progress of the calculation as it loops over the time vector.

    I tried doing this with disp():

    for j=1:length(t) %loop over time

    if(rem(j-1,100)==0) %print progress every 100 time points
    disp('time = ')
    disp(t(j))
    disp('out of ')
    disp(tfinal)

    Unfortunately, it seems like MATLAB performs all of the calculations in the for loop first and then spits out the disp() arguments after all is said and done. This doesn't accomplish my desired task. I'm finding this unexpected, as I've implemented similar progress tracking techniques in python using print statements.

    Does anyone know how to track progress in a loop?

    Thanks!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by jfortiv View Post
    Hi,

    I've been working on a simulation for a little while now. I'm to the point where I'm trying to run the simulation for a longer time period (I mean physical time represented in the simulation) than before, and I'd like to be able to track the progress of the calculation as it loops over the time vector.

    I tried doing this with disp():

    for j=1:length(t) %loop over time

    if(rem(j-1,100)==0) %print progress every 100 time points
    disp('time = ')
    disp(t(j))
    disp('out of ')
    disp(tfinal)

    Unfortunately, it seems like MATLAB performs all of the calculations in the for loop first and then spits out the disp() arguments after all is said and done. This doesn't accomplish my desired task. I'm finding this unexpected, as I've implemented similar progress tracking techniques in python using print statements.

    Does anyone know how to track progress in a loop?

    Thanks!
    does it even run without any "end"s?

    (you might find it better to send the progress tracking output to a plot window if you can)

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Oct 2009
    Posts
    20
    CB,

    I omitted the end statements when I created the post. Sorry about that. Unclear on my part. I found fprintf in one of Elbarto's recent posts. That's working for me now. I'll look into plotting the progress.

    Thanks!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 2
    Last Post: March 1st 2011, 03:04 AM
  2. Replies: 16
    Last Post: November 15th 2009, 04:18 PM
  3. [SOLVED] Something doesn't look quite right
    Posted in the Algebra Forum
    Replies: 2
    Last Post: November 13th 2009, 06:56 PM
  4. Why doesn't this function work when x<0 ?
    Posted in the Algebra Forum
    Replies: 1
    Last Post: October 30th 2009, 10:21 PM
  5. Matlab doesn't gives an error when processing
    Posted in the Math Software Forum
    Replies: 1
    Last Post: September 4th 2009, 02:05 PM

Search Tags


/mathhelpforum @mathhelpforum