フィルターのクリア

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

1 回表示 (過去 30 日間)
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?

回答 (2 件)

madhan ravi
madhan ravi 2020 年 8 月 24 日

Steven Lord
Steven Lord 2020 年 8 月 24 日
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 件のコメント
navin chandra
navin chandra 2020 年 8 月 25 日
Yes, initially the expressions obtained are symbolic expressions but I have converted them into functions by using matlabFunction.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by