Borrar filtros
Borrar filtros

problem with plotting differential equation

3 visualizaciones (últimos 30 días)
goran
goran el 5 de En. de 2014
Editada: Mischa Kim el 9 de Abr. de 2014
i have differential equation y'+y*cos(t)=sin(t)*cos(t)+4. how i can solve this equation. i used p=dsolve('Dy+y*cos(t)=sin(t)*cos(t)+4','y(0)=0') i receive p =
exp(-sin(t))*int((exp(sin(x))*(sin(2*x) + 8))/2, x == 0..t, IgnoreAnalyticConstraints)
then i used
plot(p) i receive Error using plot Conversion to double from sym is not possible.
when i use ezpolot(p,[-1,1])
i receive Error using ezplot (line 163) exp(-sin(t))*int((exp(sin(x))*(sin(2*x) + 8))/2, x == 0..t, IgnoreAnalyticConstraints) cannot be plotted in the xy-plane.
Error in sym/ezplot (line 76) h = ezplot(fhandle(f),varargin{:});
how i plot graph for differential equation
  1 comentario
Alberto
Alberto el 9 de Abr. de 2014
Some integrals can`t be solved but numerically. Try ode45 instead.

Iniciar sesión para comentar.

Respuestas (1)

Mischa Kim
Mischa Kim el 9 de Abr. de 2014
Editada: Mischa Kim el 9 de Abr. de 2014
Goran, use something like
function myODE()
tspan = 0:0.1:10;
IC = 1;
[t,y] = ode45(@ODEfun,tspan,IC);
plot(t,y,'r')
xlabel('t')
ylabel('y')
grid
end
function dY = ODEfun(t,y)
dY = -y*cos(t) + sin(t)*cos(t) + 4;
end

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by