0

I'm new to Matlab and trying to solve the Newton cooling DEQ with ODE23, actually a simplified version of it. I am not sure how to input the function into the ODE function.

I have T_s = 19, T_c = 84, and r = 0.025 elapsing from [0, 300] seconds.

The equation is (dT_c)/dt = -r(T_c - T_s)

Can anyone help me use the linked function to solve this DEQ?

Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
user3440639
  • 185
  • 2
  • 12

1 Answers1

1

Matlab supports higher order functions as well as anonymous functions. You can pass f(T_c, t) to ode23tx as follows:

ode23tx(@(T_c, T_s)(-r*(T_c - T_s), tspan, y0, arg4, varargin)

I have assumed r is constant but you can change this trivially. Read the documentation of the linked function for details of the other parameters.

Xero Smith
  • 1,968
  • 1
  • 14
  • 19