我有半個正弦,時間為 0:2*T:
Rc = 1e3;
T = 1/Rc;
Fs = 2e3; % sampling frequency
dt = 1/Fs;
over = Fs/Rc; % sampling factor - 2
sps = 10;
time = 0:dt/sps:2*T;
half_Sine = sin(pi*time/(2*T)).^3;
figure(1);
plot(time,half_Sine, 'b--o');
grid on
xlabel('time','FontSize',13);
ylabel('a(t)','FontSize',13);

但我需要時間-T/2<= 時間<= T/2。并將時間軸表示為時間/T。當我做
time = -T/2:dt/sps:T/2;
這給了我半個正弦波。所以我需要這樣的東西:

uj5u.com熱心網友回復:
1.-sin函式上的立方體防止生成的圖具有 y 軸對稱性。
Rc = 1e3;
T = 1/Rc;
Fs = 2e3; % sampling frequency
dt = 1/Fs;
over = Fs/Rc; % sampling factor - 2
sps = 10;
t =-2*T :dt/sps:2*T;
y= sin(pi*t/(2*T)).^3;
figure;
plot(t,y, 'b--o');
grid on
xlabel('time','FontSize',13);
ylabel('a(t)','FontSize',13);

2.- 要獲得最大值,t=0您需要使用cos函式,而不是sin正方形,而不是立方體
Rc = 1e3;
T = 1/Rc;
Fs = 2e3; % sampling frequency
dt = 1/Fs;
over = Fs/Rc; % sampling factor - 2
sps = 10;
t =-T :dt/sps:T;
y= cos(pi*t/(2*T)).^2;
figure(1);
plot(t,y, 'b--o');
grid on
xlabel('time','FontSize',13);
ylabel('a(t)','FontSize',13);
現在你有了 [-T T]情節,

3.- 你需要的間隔是[-T/2 T/2]
t = -T/2:dt/sps:T/2; y= cos(pi t/(2 T)).^2;
數字; 情節(t,y,'b-o');xlabel上的網格('時間','FontSize',13);ylabel('a(t)','FontSize',13);

4.- 你提到你想要標準化時間軸。
如果您修改 t 除以 T,則結果圖將是一個非常窄的時間跨度,大約 t=0 并且幾乎恒定 y=1。
相反,只需按以下方式修改x軸注釋
figure;
hp1=plot(t,y, 'b--o');
hp1.XData=hp1.XData/T
grid on
xlabel('time/T','FontSize',13);
ylabel('a(t)','FontSize',13);

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/511575.html
