上篇博文写了:【 MATLAB 】信号处理工具箱之波形产生函数 rectpuls,这篇博文是tripuls,一看就是一个类型的,所以很简单的说下。
MATLAB文档中称tripuls为采样非周期三角波(Sampled aperiodic triangle)。
语法格式:
功能描述:
就不翻译了,简单明了,看了我的上篇博文一定能明白这都是啥意思。
使用第一种形式,给一个简单的小例子:
clc
clear
close all
fs = 10e3;
t = -1:1/fs:1;
x = tripuls(t);
plot(t,x);
ylim([-0.2 1.2])
xlabel('t/s');
ylabel('amplititude');
title('tripuls');
第二种形式给定了脉冲宽度,第三种不仅给定了脉宽,还给出了偏移度百分比。负号表示左偏,正号表示右偏。
% Generate 200 ms of a symmetric triangular pulse with a sample rate of 10 kHz and a width of 40 ms
clc
clear
close all
fs = 10e3;
t = -0.1:1/fs:0.1;
w = 40e-3;
x = tripuls(t,w);
% Generate two variations of the same pulse:
%
% One displaced 45 ms into the past and skewed 45% to the left.
tpast = -45e-3;
spast = -0.45;
xpast = tripuls(t-tpast,w,spast);
% One displaced 60 ms into the future, half as wide, and skewed completely to the right.
tfutr = 60e-3;
sfutr = 1;
xfutr = tripuls(t-tfutr,w/2,sfutr);
% Plot the original pulse and the two copies on the same axes.
plot(t,x,t,xpast,t,xfutr)
ylim([-0.2 1.2])