cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Using_Odesolve_in_For_loop

ptc-4038246
1-Newbie

Using_Odesolve_in_For_loop

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

7 REPLIES 7

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:

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

We can use rkfixed for example in the for loop for the solving this (same) task.

Would you have an example Valery?

Thank you..

Rafik Borji wrote:

Would you have an example Valery?

Thank you..

See for example:

http://twt.mpei.ac.ru/ochkov/Mathcad_12/5_11_Epid_Shot.png

RichardJ
19-Tanzanite
(To:ptc-4038246)

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.

Thank you Richard,

I really appreciate the time you took to correct the problem

Rafik

Top Tags