How to make envelope of signal that connects its peaks?

3 ビュー (過去 30 日間)
Salah Alfiky
Salah Alfiky 2023 年 2 月 23 日
コメント済み: Salah Alfiky 2023 年 2 月 23 日
I want to make exactly this picture above
I used this code
clc
vmax=1;
f=50;
w=2*pi*f;
R=0.0019462;
L=3*10^-3;
Z=sqrt((R)^2+(w*L)^2);
t=[0:0.01*pi:3*pi];
alpha=0; %The parameter controls the instant on the voltage wave when short circuit occurs.
vs=sqrt(2)*vmax*sind(w*t+alpha);
%oThe short circuit is assumed to take place at t = 0
theta=rad2deg(atan(w*L/R));
is=((sqrt(2)*vmax)/Z)*sind(w*t+alpha-theta); %symmetrical sc component
it=((sqrt(2)*vmax)/Z)*sind(theta-alpha)*exp((-R/L)*t); %DC offset current2
time_constant=L/R
time_constant = 1.5415
vanish_time=5*time_constant
vanish_time = 7.7073
imm=2*max(is) %if the decay is to be neglected
imm = 3.0008
%{
This has the maximum possible value for = 0, i.e. short circuit occurring
when the voltage wave is going through zero.
%}
i=is+it;
plot(t,is,t,it,t,i)
hold on
grid on
yticks(-3:1:3)
xlim([0 vanish_time])
yline(imm)
hold off

採用された回答

Image Analyst
Image Analyst 2023 年 2 月 23 日
Did you try envelope (requires the Signal Processing Toolbox)?
  3 件のコメント
Askic V
Askic V 2023 年 2 月 23 日
THis small code should show you the trick:
t = 0:0.1:10;
y = exp(-0.1*t).*sin(10*t);
[yup,ylo] = envelope(y);
plot(t,y)
hold on
plot(t,yup,t,ylo)
Salah Alfiky
Salah Alfiky 2023 年 2 月 23 日
thank you it worked bu I added 'peak' to the attributes of the envelope function to make it look smooth
clc
vmax=1;
f=50;
w=2*pi*f;
R=0.0019462;
L=3*10^-3;
Z=sqrt((R)^2+(w*L)^2);
t=[0:0.01*pi:3*pi];
alpha=0; %The parameter controls the instant on the voltage wave when short circuit occurs.
vs=sqrt(2)*vmax*sind(w*t+alpha);
%oThe short circuit is assumed to take place at t = 0
theta=rad2deg(atan(w*L/R));
is=((sqrt(2)*vmax)/Z)*sind(w*t+alpha-theta); %symmetrical sc component
it=((sqrt(2)*vmax)/Z)*sind(theta-alpha)*exp((-R/L)*t); %DC offset current2
time_constant=L/R
time_constant = 1.5415
vanish_time=5*time_constant
vanish_time = 7.7073
imm=2*max(is) %if the decay is to be neglected
imm = 3.0008
%{
This has the maximum possible value for = 0, i.e. short circuit occurring
when the voltage wave is going through zero.
%}
i=is+it;
[yup, ydown]=envelope(i,30,'peak');
plot(t,i)
hold on
plot(t,is,"LineStyle","--")
plot(t,it,"LineStyle","--")
grid on
yticks(-3:1:3)
xlim([0 vanish_time])
yline(imm)
ylabel("Short Circuit Current (A) / Voltage (V)")
xlabel("time (s)")
plot(t,vs)
plot(t,yup,"LineStyle","--")
plot(t,ydown,"LineStyle","--")
legend("Total SC Current","is","it","Vs")
hold off

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by