Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Iteration calculation inconsistencies

Iteration calculation inconsistencies

Iteration calculation inconsistencies

I am currently performing an iteration calculation for a model that involves variably changing acceleration. The acceleration is dependent on position for this model. When I plot the data with respect to position, the data is accurate. However, when I plot it with respect to time the acceleration, speed, and position values are OK, but the time span that the motion undergoes is very inaccurate. It gets even worse when I try to decrease the time interval for each iteration. The time span that it is suppose to be is approximately 5-7 ms, but with small time intervals I get time spans that go from 1.4 ms to as small as 1e-4 ms (using a time interval as large as 0.1 ms and as small as 1e-8 ms).

Is this just computation issues within MATLAB or is this a major error within the code?

RE: Iteration calculation inconsistencies

I spend a reasonable amount of my time writing and using matlab scripts. I spend a lot more of my time doing dynamic simulations. I cannot see any way to answer your question from the information given. However, I have found that generally matlab does what you ask it to do. So the chances are you are asking it to do something other than what you think you are asking it to do.


Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

RE: Iteration calculation inconsistencies

"a major error within the code?"

Your code or Matlab? From what little info you've provided, my first guess is that you are solving an ODE problem using a variable step built-in solver, which is dynamically adjusting its step-size based on the required error tolerance - typically shrinking it when current conditions make the equations stiffen up.

- Steve

RE: Iteration calculation inconsistencies

When I say within Matlab I am referring to errors that arise in Matlab such as round off errors or truncation errors. The time steps I am using are really small so my inital guess was the time steps were being truncated during calculation steps within the code.

I have tried to set up my system as a PDE but the only relation I have is that the acceleration is dependent upon angular position and I have absolutely no reference to time except the typical conditions of 0 displacement at time=0.

Due to this, I have tried to set up small time step iterations that assume near constant acceleration within the time step and then calculate the position and speed using the standard kinematic equations. With the new position I adjust the acceleration as such for the next iteration. In my point of view, doing it this way at least has references to both position and time. However, using this method is only consistent when comparing acceleration and speed to position instead of time. I am thinking that time becomes an arbitrary reference frame and adjusts itself according to the time interval that is used for each iteration.

RE: Iteration calculation inconsistencies

If you created the time stepping, then whatever the time step does is because of your programming, not Matlab's. Likewise, any errors are probably due to your model and how you are attempting to solve it. The smallest real number representation is a 32-bit float, which accommodates something like 15 decimal places of precision.

FAQ731-376: Eng-Tips.com Forum Policies

Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers

RE: Iteration calculation inconsistencies

After all this analysis that is what I am figuring but how its making these inconsistencies I am not sure. I just find it out that if I decrease the time interval per iteration, the overall time span decreases, and vice versa if I increase the itme interval. Almost every iteration type of analysis I have performed has always kept a pretty consistent time span regardless of the interval used.

RE: Iteration calculation inconsistencies

First sounded like a non-linear ODE (you were talking about acceleraiton and position... sounds like lumped element mass spring model.

Then you mentioned PDE. It's not clear what type of pde you wouild be solving.

Might be interesting to know a little more details on the problem and your approach. Lumped element ode? Using ode45?

(2B)+(2B)' ?

RE: Iteration calculation inconsistencies

Lack of information. It now sounds like you have written your own solver:

- Fixed time-steps as an input to the solver
- Inner convergence loop based on meeting some kind of error condition
- Some derivatives assumed constant across time-step (i.e. Euler integration!)

And you are finding that a smaller time-step runs faster, although you do not clearly distinguish between simulation time and wall time. I can't tell whether (a) each time-step is faster when the step-length is smaller (the inner convergence loop needs less iterations), or (b) the whole simulation completes more quickly with (more) smaller time-steps.

At least that's what I can glean from the posts so far.

- Steve

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close