plot just y or y' in a second order eq.

1 visualización (últimos 30 días)
Saladin Hossam
Saladin Hossam el 4 de Ag. de 2020
Respondida: Walter Roberson el 4 de Ag. de 2020
so i when i use the order of ploting it plots y, y', x and x' i just wanna it to plot just y' and x the other two remove them
format long
syms y(t) x(t)
[V] = odeToVectorField(diff(y, 2) == -1*(1-1*cos(2*t))*y);
M = matlabFunction(V,'vars', {'t','Y'});
[t,y] = ode45(@(t,Y)M(t,Y),tspan,[0 1]);
[t,x] = ode45(@(t,Y)M(t,Y),tspan,[1 0]);
hold on
plot(t,x)
plot(t,y)
hold off

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Ag. de 2020
syms y(t) x(t)
[V] = odeToVectorField(diff(y, 2) == -1*(1-1*cos(2*t))*y);
M = matlabFunction(V,'vars', {'t','Y'});
[ty,y] = ode45(@(t,Y)M(t,Y),tspan,[0 1]);
[tx,x] = ode45(@(t,Y)M(t,Y),tspan,[1 0]);
hold on
plot(tx, x(:,1));
plot(ty, y(:,2));
hold off
legend({"x", "y'"})

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by