Plotting lissajous (phase figure) I obtained the plot in photo 1, but I shoould have the plot of figure 2. Could someone please help me figure out the mistake?
c = 1; b = 0.1; a = 0.45; d = 1; %-1
w=1.3; %obtaining the solution to second order differential equation x'' + bx' − x + x^3 = a sin (wt). this is duffing holmes equation
%the equation was converted to a system of 2 equations y=x' and y' = d*x - c*x^3 − by + a sin(wt)
%this link was used to solve 2 order ODE https://www.mathworks.com/help/symbolic/solve-differential-equation-numerically-1.html
syms y(t) [V] = odeToVectorField(diff(y, 2) == d*y - c*y^3-b*diff(y) + a*sin(w*t)); M = matlabFunction(V,'vars', {'t','Y'}); sol = ode45(M,[0 100],[2 2]); figure (1) fplot(@(x)deval(sol,x, 1), [0 100]); title('position vs time'); xlabel('time t'); ylabel ('position x'); %differentiating with respect to time and plotting velocity vs position
dY = diff(sol.y); dYY=dY(:,1:end-1); dX = diff(sol.x); der = dYY./dX; disp = sol.y; disp2 = disp(:,1:end-1); figure (2) plot(disp2, der, 'r-'); title('Lissajous Figure'); xlabel('position'); ylabel ('velocity');
Best Answer