what the problem that I get to during plotting the graph

3 ビュー (過去 30 日間)
SAHIL SAHOO
SAHIL SAHOO 2022 年 7 月 10 日
編集済み: Torsten 2022 年 7 月 11 日
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
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
y(1) = A1
y(2) = A2
y(3) = G1
y(4) = G2
y(5) = Φ

回答 (1 件)

VBBV
VBBV 2022 年 7 月 11 日
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 件のコメント
SAHIL SAHOO
SAHIL SAHOO 2022 年 7 月 11 日
I couln't found any suitable initial condition for which the waveform is proper and please can you check if my algorithm is correct for solving the differential equation that I gave you in the picture.
Torsten
Torsten 2022 年 7 月 11 日
編集済み: Torsten 2022 年 7 月 11 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by