0
對於正方形,矩形和y軸上的鋸齒信號,我有一個從0到1的信號,我如何將信號向下移動(垂直偏移),使信號從-0.5到在y軸上爲0.5,並將三角形信號從0.5變爲1.0至-0.5至0.5?將信號向下移動
clear all
% SCRIPT BEGINS
t=linspace(0,1,22050)
freq=5%how many times it repeats in 1 sec
A = 1; % amplitude
T = 1/freq; % period of the signal
% square
square = mod(t * A/T, A) > A/2;
plot(t, square)
title('Square');
% rectangle
l = 0.2; % percentage the signal spends on low value
rectangle = mod(t * A/T, A) > A * l;
figure;
plot(t, rectangle);
title('Rectangle');
% sawtooth
sawtooth = mod(t * A/T, A);
figure;
plot(t, sawtooth);
title('Sawtooth');
% triangle
triangle = (mod(t * A/T, A) > 0.5).*mod(t * A/T, A) + (mod(t * A/T, A) <= 0.5).*(1 - mod(t * A/T, A));
figure;
plot(t, triangle);
title('triangle');
感謝我使用八度/ MATLAB