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

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

Respuesta aceptada

Kenta
Kenta el 21 de Feb. de 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 comentarios
Akira Agata
Akira Agata el 24 de Feb. de 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 el 25 de Feb. de 2020
Kenta さん、Akira Agata さん、回答ありがとうございます。位相シフトすることができました。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!