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

17 views (last 30 days)
Musashi Ito
Musashi Ito on 21 Feb 2020
Commented: Musashi Ito on 25 Feb 2020
Singal Processing Toolbox の sawtooth 関数 で三角波をプロットしたく、以下のドキュメンテーションを参考にしてます。
波形の位相を45°や90°シフトしたい時はどのようにプログラムを記述すればできますか?

Accepted Answer

Kenta
Kenta on 21 Feb 2020
こんにちは、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 Comments
Akira Agata
Akira Agata on 24 Feb 2020
もしくは、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 on 25 Feb 2020
Kenta さん、Akira Agata さん、回答ありがとうございます。位相シフトすることができました。

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!