How to create a new function file using functions and variables available in base workspace?

1 visualización (últimos 30 días)
I have created one MATLAB code which gives me N1 , N2 and N3 (saved in base workspace) all as a very big nasty functions of variable r. Now I have to solve a second order ODE by using ode45 for which I need to define a function that contains RHS of the ODE. But the RHS of my ODE conatins N1,N2,N3,r and some other variables from base workspace. So, I am not able to define this new function for RHS of ODE because that new function is not capturing the variables from base workspace. What should I do?

Respuestas (2)

madhan ravi
madhan ravi el 24 de Ag. de 2020

Steven Lord
Steven Lord el 24 de Ag. de 2020
If the functions are "big nasty functions" I'm guessing they're symbolic expressions. If so use dsolve to solve symbolically or use odeFunction (both those functions are listed on this documentation page) to convert it into a form the numeric ODE solvers like ode45 can handle.
  1 comentario
navin chandra
navin chandra el 25 de Ag. de 2020
Yes, initially the expressions obtained are symbolic expressions but I have converted them into functions by using matlabFunction.

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by