Skip to main content
1-Visitor
December 16, 2011
Question

Using_Odesolve_in_For_loop

  • December 16, 2011
  • 1 reply
  • 3299 views

Hello,

I have a second order Ode with an excitation term this excitation term is a matrix function so I have to solve the ode at each coordinate (i,j).

Is it possible to include the Odesolve iside a for loop (2 for loops on i and j)?

I am attaching what I wrote in mathcad

Thank you in advance

1 reply

23-Emerald I
December 16, 2011

What should the units of xd and zd be?

I'm not sure what you're trying to do. Your variable "y" looks like time. What are the matrices xd and zd (looks like position and acceleration, but why distributed?)

Odesolve(y,500) returns a function, so Y := Odesolve(y,500) can then be evaluated at any value of y as (Y(y)=.

Several files to get you started:

1-Visitor
December 17, 2011

Thank you for the a nswer but let me explain more what I am trying to do. my external force (zd) is a matrix function (as you said distributed). I am varying the period (i increment) of the sine function and the amplitude (j increment). That's why I have a matrix function of the exitation. and I need to get a solution of the ODE for each element function of the matrix.

Hope that this explains what I want to do. So I am trying to solve the ODE in a two-for-loop fashion.

Rafik

19-Tanzanite
December 17, 2011

The key is in the first of the example sheets Fred posted. You need to turn the solve block into a function (since it's Odesolve, that is then a function that returns a function). Once that's done it works, but to get it to work in a reasonable time you also need to change your exceedingly inefficient definition of the function zd. See the attached.