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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by