How do I get phase section of this equation?

조회 수: 2 (최근 30일)
Joo Seo Lee
Joo Seo Lee 2020년 4월 25일
편집: Ameer Hamza 2020년 4월 25일
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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 25일
편집: Ameer Hamza 2020년 4월 25일
Try this
W = 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);
end
tiledlayout('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))]);
end
The tiledlayout will work for R2019b and onward. For older versions using the following lines to plot the figure
figure;
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by