Solving coupled ode in matlab help

In summary: If the resulting current value is lower than expected, check your calculations and make sure you have correctly implemented the equations and initial conditions.
  • #1
cjh12398
6
0
Problem: Model the coupled ode system for a motor:
Equations:
dVc/dt=(-1/C)*Il+(1/C)Is
dIl/dt=(1/L)*Vc-(R/L)*Il

I have been given the values of L=1e-3, R=50, Is=10.0A and C is to be designed by trial and error.
I have been able to write out the function, by assigning Vc=x(1) and Il=x(2), and then I wrote dxdt= [dVc/dt;dIl/dt];

But when I have my script, I'm having trouble in how to define the initial conditions. The task says that all currents and voltages are zero at the beginning and I have therefore written that x1=0 and x2=0.

However, when I plot the result, the current value is way lower than what is expected.
I suspect there is a problem in the way I am defining the initial conditions.
Any help would be greatly appreciated.
 
Physics news on Phys.org
  • #2
Solution: In this case, you should use the given values of L, R, and Is to calculate the initial conditions for your system. The initial voltage Vc can be calculated from the equation dVc/dt=(-1/C)*Il+(1/C)Is, as Vc(0)=(Is*C). Similarly, the initial current Il can be calculated from the equation dIl/dt=(1/L)*Vc-(R/L)*Il, as Il(0)=(Vc(0)*L)/R. Thus, you should use these initial conditions, x1=Vc(0) and x2=Il(0), when defining your system.
 

Related to Solving coupled ode in matlab help

1. How do I solve coupled ODEs in MATLAB?

To solve coupled ODEs in MATLAB, you can use the "ode45" function which is a built-in solver for systems of ordinary differential equations. You will need to define your coupled ODEs as a function and then pass it as an argument to the "ode45" function along with the initial conditions and time interval.

2. What is the syntax for solving coupled ODEs in MATLAB?

The syntax for solving coupled ODEs in MATLAB using the "ode45" function is as follows:
[t, y] = ode45(@odefun, tspan, y0);
where "odefun" is the name of the function that defines your coupled ODEs, "tspan" is the time interval, and "y0" is the initial conditions.

3. Can I solve higher-order coupled ODEs in MATLAB?

Yes, you can solve higher-order coupled ODEs in MATLAB by first converting them into a system of first-order ODEs. This can be done by defining new variables for the derivatives of the higher-order variables. Then, you can use the "ode45" function as usual to solve the system of first-order ODEs.

4. How can I plot the solution for coupled ODEs in MATLAB?

To plot the solution for coupled ODEs in MATLAB, you can use the "plot" function. You will need to pass the time vector and the corresponding values of the solution vector as arguments to the "plot" function. You can also add labels and customize the plot as needed.

5. Can I solve coupled ODEs with non-constant coefficients in MATLAB?

Yes, you can solve coupled ODEs with non-constant coefficients in MATLAB by defining the coefficients as functions within the "odefun" function. Then, you can pass the functions as arguments to the "ode45" function along with the other arguments. This will allow you to solve for the solution of the coupled ODEs with varying coefficients.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top