sawtooth 関数で三角波の位相をシフトしたい

37 ビュー (過去 30 日間)
Musashi Ito
Musashi Ito 2020 年 2 月 21 日
コメント済み: Musashi Ito 2020 年 2 月 25 日
Singal Processing Toolbox の sawtooth 関数 で三角波をプロットしたく、以下のドキュメンテーションを参考にしてます。
波形の位相を45°や90°シフトしたい時はどのようにプログラムを記述すればできますか?

採用された回答

Kenta
Kenta 2020 年 2 月 21 日
こんにちは、sawtooth(t)自体はtでののこぎり波の値を返すので、プロットするxの値をずらして、
ずらしたxの値とsawtoothの値を対応させればちょうどご質問のようなデータを作成できると思ったのですがいかがでしょうか。例えば下のコードだと、pi/2分ずらすことができている気がします...
clear;clc;close all
fundamentalFrequency=1/2;%unit:Hz
numWave=4;
T = numWave*(1/fundamentalFrequency)*pi;%T repreesents the x value to terminate
fs = 100;% number of plots
t = 0:T/fs:T-1/fs;
PhaseShift=1/2*pi;
x = sawtooth(t);
figure;
plot(t,x);hold on;plot(t-PhaseShift,x-2)
set(gca,'XTick',0:2*pi:8*pi)
set(gca,'XTickLabel',{'0','2pi','4pi','6pi','8pi'})
grid on
  2 件のコメント
Akira Agata
Akira Agata 2020 年 2 月 24 日
もしくは、sawtooth関数の入力引数で位相シフト量を指定しても良いかもしれません。
たとえばドキュメンテーションの例をベースに、π/2 だけ位相シフトした波形を生成する一例を以下に示します。
T = 10*(1/50);
fs = 1000;
t = 0:1/fs:T-1/fs;
phaseShift = pi/2;
x1 = sawtooth(2*pi*50*t,1/2);
x2 = sawtooth(2*pi*50*t - phaseShift,1/2);
figure
plot(t,x1)
hold on
plot(t,x2)
legend({'w/o \phi shift','w/ \phi shift (\pi/2)'},'FontSize',12)
grid on
Musashi Ito
Musashi Ito 2020 年 2 月 25 日
Kenta さん、Akira Agata さん、回答ありがとうございます。位相シフトすることができました。

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!