MATLAB: How to get phase section of this equation phase sectiontwo variables the equation is y=dx/dt dy/dt=-0.05y-sin(x)+0.7 cos(wt) w is given 0.1, 0.2, 0.3… to 1.5 I can't set any equation as both equations are contataing both variables, and I want to get the graph of x and y Best Answer Try thisW = 0.1:0.1:1.5;odefun = @(t,X,w) [X(2); -0.05*X(2)-sin(X(1))+0.7*cos(w*t)];t = 0:0.1:10;ic = [0;0];X_sol = cell(1,numel(W));for i=1:numel(W) [~, X_sol{i}] = ode45(@(t,X) odefun(t, X, W(i)), t, ic);endtiledlayout('flow')for i=1:numel(X_sol) nexttile plot(X_sol{i}(:,1), X_sol{i}(:,2)); xlabel('x') ylabel('y') title(['w = ' num2str(W(i))]);endThe tiledlayout will work for R2019b and onward. For older versions using the following lines to plot the figurefigure;for i=1:numel(X_sol) subplot(4,4,i); plot(X_sol{i}(:,1), X_sol{i}(:,2)); xlabel('x') ylabel('y') title(['w = ' num2str(W(i))]);end Related SolutionsMATLAB: How to add direction line into the phase plane plot Alex, use quiver. In quiver(x,y,u,v)the x, y are the grid points, u and v you get from the dX vector from the differential equations function. MATLAB: How to solve differential equation in while/for loop using ODE45 function yprime = cycfun(t,y,K) a = 0.18; b = 0.2; c = 5.7; n = 12; i = 1; f = []; while i < n f = [f;-(y(i+1)+y(i+2));(y(i) + a*y(i+1)); b+y(i+2)*(y(i)-c)]; i = i+3; end yprime = f - (K*y);Best wishesTorsten. Related QuestionUsing ODE45 to solve simultaneously independent ODE’s vs. calling the function twice – different results…Does the following simple Harmonic oscillator (without damping) behave as a damped harmonic oscillatorNeed some help, Four coupled ODEs with ode45
Best Answer