Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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?

Antworten (2)

madhan ravi
madhan ravi am 24 Aug. 2020

Steven Lord
Steven Lord am 24 Aug. 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 Kommentar
navin chandra
navin chandra am 25 Aug. 2020
Yes, initially the expressions obtained are symbolic expressions but I have converted them into functions by using matlabFunction.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by