what the problem that I get to during plotting the graph
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ti = 0;
tf = 10E-4;
tspan=[ti tf];
y0=[10;10;1;1;1].*10E-2;
[T,Y]= ode45(@(t,y) rate_eq(t,y),tspan,y0);
plot(T,Y(:,1));
xlim([0 4E-4])
ylim([0 8])
xlabel('time')
ylabel('amplitude')
yyaxis right
ylabel('phase difference')
hold on
plot(T,((Y(:,5))./6.28));
hold off
function dy = rate_eq(t,y)
dy = zeros(5,1);
o = 2E5;
tc = 30E-9;
tf = 230E-6;
a1 = 0.1;
a2 = 0.1;
P1 = 0.2;
P2 = 0.2;
kc = 3E-3;
s = 0.17;
k = s.*kc;
dy(1) = ((y(3) - a1) * y(1) + k * y(2) * cos(y(5))) / tc;
dy(2) = ((y(4) - a2) * y(2) + k * y(1) * cos(y(5))) / tc;
dy(3) = (P1 - y(3) * (y(1)^2 + 1)) / tf;
dy(4) = (P2 - y(4) * (y(2)^2 + 1)) / tf;
dy(5) = o - k / tc * (y(1) / y(2) + y(2) / y(1) * sin(y(5)));
end
I have marked the circle which part is not proper waveform and I need a proper waveform with same amplitude, I need to know what is causing this, is it the constant value which I have given , initial conditions or something
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1060675/image.png)
and please check that if I solve the differential equation correctly or not, I mean the techinques that I apply to solve this differential equation.
these are the differential equation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1060680/image.jpeg)
y(1) = A1
y(2) = A2
y(3) = G1
y(4) = G2
y(5) = Φ
0 comentarios
Respuestas (1)
VBBV
el 11 de Jul. de 2022
ti = 0;
tf = 10E-4;
tspan=[ti tf];
y0=[2;2;1;1;1].*10E-2; % this change
[T,Y]= ode45(@(t,y) rate_eq(t,y),tspan,y0);
plot(T,Y(:,1));
xlim([0 4E-4])
ylim([0 8])
xlabel('time')
ylabel('amplitude')
yyaxis right
ylabel('phase difference')
hold on
plot(T,((Y(:,5))./6.28));
hold off
function dy = rate_eq(t,y)
dy = zeros(5,1);
o = 2E5;
tc = 30E-9;
tf = 230E-6;
a1 = 0.1;
a2 = 0.1;
P1 = 0.2;
P2 = 0.2;
kc = 3E-3;
s = 0.17;
k = s.*kc;
dy(1) = ((y(3) - a1) * y(1) + k * y(2) * cos(y(5))) / tc;
dy(2) = ((y(4) - a2) * y(2) + k * y(1) * cos(y(5))) / tc;
dy(3) = (P1 - y(3) * (y(1)^2 + 1)) / tf;
dy(4) = (P2 - y(4) * (y(2)^2 + 1)) / tf;
dy(5) = o - k / tc * (y(1) / y(2) + y(2) / y(1) * sin(y(5)));
end
Yes, the constant values given as initial conditions need to be modified to get proper waveform.
2 comentarios
Torsten
el 11 de Jul. de 2022
Editada: Torsten
el 11 de Jul. de 2022
dy(5) doesn't coincide with your equation in the picture.
And we don't know whether I1 = y(1)^2 and I2 = y(2)^2.
ti = 0;
tf = 10E-4;
tspan=[ti tf];
y0=[10;10;1;1;1].*10E-2; % this change
options = odeset('RelTol',1e-8,'AbsTol',1e-8);
[T,Y]= ode45(@(t,y) rate_eq(t,y),tspan,y0,options);
plot(T,Y(:,1));
xlim([0 4E-4])
ylim([0 8])
xlabel('time')
ylabel('amplitude')
yyaxis right
ylabel('phase difference')
hold on
plot(T,((Y(:,5))./6.28));
hold off
function dy = rate_eq(t,y)
dy = zeros(5,1);
o = 2E5;
tc = 30E-9;
tf = 230E-6;
a1 = 0.1;
a2 = 0.1;
P1 = 0.2;
P2 = 0.2;
kc = 3E-3;
s = 0.17;
k = s.*kc;
dy(1) = ((y(3) - a1) * y(1) + k * y(2) * cos(y(5))) / tc;
dy(2) = ((y(4) - a2) * y(2) + k * y(1) * cos(y(5))) / tc;
dy(3) = (P1 - y(3) * (y(1)^2 + 1)) / tf;
dy(4) = (P2 - y(4) * (y(2)^2 + 1)) / tf;
dy(5) = o - k / tc * (y(1) / y(2) + y(2) / y(1)) * sin(y(5));
end
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!