how to solve the program?

8 Ansichten (letzte 30 Tage)
prajith samraj
prajith samraj am 18 Jul. 2022
Bearbeitet: prajith samraj am 26 Jul. 2022
Unrecognized function or variable 'e1'.
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 Kommentare
prajith samraj
prajith samraj am 18 Jul. 2022
i need e1 and e2 graph. what can i do?
Lateef Adewale Kareem
Lateef Adewale Kareem am 19 Jul. 2022
e1 = y(:,3)-y(:,1);
e2= y(:,4)-y(:,2);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sam Chak
Sam Chak am 19 Jul. 2022
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 Kommentare
prajith samraj
prajith samraj am 19 Jul. 2022
i need the value of e1dot and e2 dot graph
Sam Chak
Sam Chak am 19 Jul. 2022
@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...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by