MATLAB DSOLVE: Solving 2nd Order ODEs with Initial Conditions

  • Thread starter ganeshrk
  • Start date
  • Tags
    Matlab
In summary, if you are experiencing long run times with DSOLVE for solving a large number of ODEs, it may be beneficial to explore alternative methods and seek advice from others who have experience in this area.

What would you suggest?

  • Accept long hours solution time

    Votes: 0 0.0%
  • Use a different way to solve ODE

    Votes: 0 0.0%
  • Improve the code

    Votes: 0 0.0%
  • run on a faster machine

    Votes: 0 0.0%

  • Total voters
    0
  • Poll closed .
  • #1
ganeshrk
3
0

Homework Statement


I am using MATLAB Symbolic Tool Box "Dsolve"
to solve 2nd order, linear, ordinary, non-homogenous differential equation with initial conditions.

Homework Equations



Equation of motion with base excitation (vibration: single degree of freedom system)

The Attempt at a Solution



Calculating response spectrum for frequency range 1 to 1000 with 1000 time-steps for piecewise linearized base acceleration input (forcing function).
That is 1 million times solving the ODE using DSOLVE.
It takes 0.6 secs for 1 time on a 64bit machine. For 1 million times it will take 166 hours, almost a week!
Is there anyway we can speed up the process?

What do you suggest?


 

Attachments

  • tryingdsolve2.m
    3 KB · Views: 383
Physics news on Phys.org
  • #2


I would suggest looking into alternative methods for solving the differential equation, such as numerical methods. These methods are designed specifically for handling large numbers of calculations and can often be more efficient than symbolic methods like DSOLVE. Additionally, you could also consider optimizing your code and using parallel computing techniques to speed up the process. Another option could be to use a more powerful computer or to distribute the calculations across multiple machines. Ultimately, it may also be helpful to consult with experts in the field or colleagues who have experience with similar problems to see if they have any suggestions or insights.
 

Related to MATLAB DSOLVE: Solving 2nd Order ODEs with Initial Conditions

1. How do I solve a second order ODE using MATLAB DSOLVE?

To solve a second order ODE using MATLAB DSOLVE, you first need to define the differential equation using the dsolve function. Then, specify the independent variable and the initial conditions. Finally, use the odeToVectorField function to convert the ODE into a system of first order ODEs, and use the ode45 or ode15s function to solve the system of equations.

2. What are the required inputs for the dsolve function?

The required inputs for the dsolve function are the differential equation, the independent variable, and the initial conditions. The differential equation should be in the form of dy/dx = f(x,y), where y is the dependent variable. The independent variable is usually denoted as x, and the initial conditions specify the values of y and dy/dx at a given point.

3. Can I solve a second order ODE with non-constant coefficients using MATLAB DSOLVE?

Yes, MATLAB DSOLVE can handle second order ODEs with non-constant coefficients. You can specify the coefficients as symbolic functions or as numerical values. However, if the coefficients are functions of both x and y, you need to use the dsolve function with the 'IgnoreAnalyticConstraints' option.

4. How can I visualize the solution to a second order ODE using MATLAB DSOLVE?

You can use the ode45 or ode15s functions to obtain the numerical solution to the ODE. Then, you can use the plot function to visualize the solution curve. You can also use the dsolve function to obtain the analytical solution, and then use the ezplot function to plot the solution curve.

5. Can I solve a system of second order ODEs using MATLAB DSOLVE?

Yes, you can use MATLAB DSOLVE to solve a system of second order ODEs. You need to use the odeToVectorField function to convert the system into a set of first order ODEs, and then use the ode45 or ode15s function to solve the system of equations. You can also specify initial conditions for each of the equations in the system.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
938
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Math POTW for University Students
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Differential Equations
Replies
4
Views
1K
Back
Top