How do i plot a function that is dependent of itself

조회 수: 4 (최근 30일)
guilherme gonçalves
guilherme gonçalves 2019년 11월 5일
답변: Star Strider 2019년 11월 5일
Hello, i am having trouble ploting .
I realy don´t know where to start, i am new to MATLAB.
  댓글 수: 1
ME
ME 2019년 11월 5일
Just checking, do you actually want to plot the value of dh(t)/dt or do you want to plot the solution to that differential equation?
Either way, it would be useful to have some more details on what each of your symbols are. For example, are m(t) and p^2(t) variables, time-dependent parameters/functions etc.
I think we are probably safe to assume A, C and G are all constant parameter values?

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2019년 11월 5일
You posted a differential equation, so in order to solve for ‘h’ you need to integrate it. It does not likely have an analytic, closed-form solution, since it is nonlinear in ‘h’.
One approach:
syms A C G h(t) m p(t) Y
m(t) = t; % Provide The Correct Function
p(t) = 2*t; % Provide The Correct Function
Eqn = diff(h) == (m(t)-C*p(t)^2*sqrt(2*G*h(t)))/A;
[VF,Subs] = odeToVectorField(Eqn)
h_fcn = matlabFunction(VF, 'Vars',{t,Y,A C G})
Then solve it using one of the numeric solvers, such as ode45. After you integrate it with the numeric solver, you can evalurate ‘h_fcn’ in a for loop using the solved values as input, to get the derivative , or you can just use the gradient function, if you have defined ‘tspan’ to be a vector of more than two regularly-sampled values.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by