How do i plot a function that is dependent of itself
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
guilherme gonçalves
am 5 Nov. 2019
Beantwortet: Star Strider
am 5 Nov. 2019
Hello, i am having trouble ploting
.
I realy don´t know where to start, i am new to MATLAB.
1 Kommentar
ME
am 5 Nov. 2019
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?
Akzeptierte Antwort
Star Strider
am 5 Nov. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!