how to solve the program?
조회 수: 8 (최근 30일)
이전 댓글 표시
s1=x3.^2+x1*x3+x1.^2;
s2=x1.^4+x1.^3*x3+x1.^2*x3.^2 +x1.^2*x3.^2+x1*x3.^3 + x3.^4;
%s1=x2.^2+x1*x2+x1.^2;
%s2=x1.^4+x1.^3*x2+x1.^2*x2.^2 +x1.^2*x2.^3 + x2.^4;
%u1 = -e1-e2;
%u2 = beta*e1*k1 +gamma*e1*k2+omegaf*e1-ff2*cos(W2*t)+ff1*cos(W1*t);
u1 = -e2-e1;
u2 = beta*e1*s1 + gamma*e1*s2+omegaf*e1-ff2*cos(W2*t)+ff1*cos(W1*t);
%sys-I
dx1=x2;
dx2=-alpha*x2-omegaf*x1-beta*x1.^3- gamma*x1.^5+ff1*cos(W1*t);
%sys -II
dx3=x4+u1;
dx4=-alpha*x4-omegaf*x3-beta*x3.^3- gamma*x3.^5+ff2*cos(W2*t)+u2;
de1=dx3-dx1;
de2=dx4-dx2;
e1 = x3-x1;
e2= x4-x2;
de1=e2+u1;
de2=-alpha*e2-omegaf*e1-beta*e1*s1- gamma*e1*s2+ff2*cos(W2*t)-ff1*cos(W1*t)+u2;
dy = [dx1; dx2; dx3; dx4];
end
댓글 수: 2
채택된 답변
Sam Chak
2022년 7월 19일
Try manipulating the parameters to get different results.
% Solver
tspan = [0 20];
x10 = 0.11;
x20 = 0.1;
x30 = 0.21;
x40 = 0.2;
y0 = [x10; x20; x30; x40];
[t, y] = ode45(@(t, y) f(t, y), tspan, y0);
% Plots
e1 = y(:, 3) - y(:, 1);
e2 = y(:, 4) - y(:, 2);
subplot(2,1,1)
plot(t, e1), grid on, xlabel('t'), ylabel('e_{1}')
subplot(2,1,2)
plot(t, e2), grid on, xlabel('t'), ylabel('e_{2}')
function dy = f(t, y)
% parameters
alpha = 0.5;
omegaf = -1;
beta = 0.8790;
gamma = 0.3000;
W1 = 1.4450;
ff1 = 0.5381;
W2 = 1.4450;
ff2 = 0.5381;
% assignment
x1 = y(1);
x2 = y(2);
x3 = y(3);
x4 = y(4);
e1 = x3 - x1;
e2 = x4 - x2;
s1 = x3^2 + x1*x3 + x1^2;
s2 = x1^4 + (x1^3)*x3 + (x1^2)*(x3^2) + (x1^2)*(x3^2) + x1*(x3^3) + x3^4;
u1 = - e2 - e1;
u2 = beta*e1*s1 + gamma*e1*s2 + omegaf*e1 - ff2*cos(W2*t) + ff1*cos(W1*t);
% sys I
dx1 = x2;
dx2 = - alpha*x2 - omegaf*x1 - beta*x1^3 - gamma*x1^5 + ff1*cos(W1*t);
% sys II
dx3 = x4 + u1;
dx4 = - alpha*x4 - omegaf*x3 - beta*x3^3 - gamma*x3^5 + ff2*cos(W2*t) + u2;
de1 = dx3 - dx1;
de2 = dx4 - dx2;
dy = [dx1; dx2; dx3; dx4];
end
댓글 수: 2
Sam Chak
2022년 7월 19일
@prajith samraj, I'm a little confused now. In your comment, you clearly mentioned that you need e1 and e2 graph. Perhaps, you unintentionally confused yourself with e1dot and e2dot?
Please edit the title of your question for clarity...
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Filter Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!