How do i plot a function that is dependent of itself
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
guilherme gonçalves
el 5 de Nov. de 2019
Respondida: Star Strider
el 5 de Nov. de 2019
Hello, i am having trouble ploting
.
I realy don´t know where to start, i am new to MATLAB.
1 comentario
ME
el 5 de Nov. de 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?
Respuesta aceptada
Star Strider
el 5 de Nov. de 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 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!