【 MATLAB 】信號處理工具箱之波形產(chǎn)生函數(shù) rectpuls
這個(gè)函數(shù)在matlab的幫助文檔中,稱為采樣非周期矩形波(Sampled aperiodic rectangle),說白了,也就是一個(gè)矩形脈沖,你可以通過該函數(shù)控制脈沖的位置,以及脈沖的寬度等。
語法:
幫助文檔對這兩種語法形式的描述為:
y?=?rectpuls(t)?returns a continuous, aperiodic, unity-height rectangular pulse at the sample times indicated in array?t, centered about?t?=?0?and with a default width of 1. Note that the interval of nonzero amplitude is defined to be open on the right, that is,?rectpuls(-0.5)?=?1?while?rectpuls(0.5)?=?0.
y?=?rectpuls(t,w)?generates a rectangle of width?w.
不仔細(xì)分析還真的讓人看不太懂,我簡單的理解下,然后用例子說明:
y?=?rectpuls(t)返回一個(gè)連續(xù)的、非周期的、單位高度的矩形脈沖,數(shù)組t指示了矩形脈沖顯示在多大的一個(gè)時(shí)間范圍內(nèi),矩形脈沖的中心位于 t = 0時(shí)刻,默認(rèn)的脈寬為1.最后需要說明的是,矩形脈沖的非零幅度值位于區(qū)間[-0.5,0.5)內(nèi),注意是左閉右開。
如下:
t = -1:.5:1
x = rectpuls(t)
可見,t = -0.5時(shí),x = 1;t = 0.5, x = 0。
作個(gè)小圖來看看:
clc
clear
close all
fs = 10e3;
t = -1:1/fs:1;
x = rectpuls(t);
plot(t,x);
ylim([-0.2 1.2])
xlabel('t/s');
ylabel('amplititude');
title('rectpuls');
明白了吧。
y?=?rectpuls(t,w)?,這種語法形式,只不過指定了該矩形脈沖的位寬,其他和上一種形式一樣。
給一個(gè)例子:
% Generate 200 ms of a rectangular pulse with a sample rate of 10 kHz and a width of 20 ms.
clc
clear
close all
fs = 10e3;
t = -0.1:1/fs:0.1;
w = 20e-3;
x = rectpuls(t,w);
% One displaced 45 ms into the past.
tpast = -45e-3;
xpast = rectpuls(t-tpast,w);
% One displaced 60 ms into the future and half as wide.
tfutr = 60e-3;
xfutr = rectpuls(t-tfutr,w/2);
% Plot the original pulse and the two copies on the same axes.
plot(t,x,t,xpast,t,xfutr)
ylim([-0.2 1.2])
xlabel('t/s');
ylabel('amplititude');
title('rectpuls');
%add legend for the above function
lgd = legend('now', 'past', 'further');
lgd.Location = 'northwest';
title(lgd,'my legend title');
legend boxoff
畫了這張圖,才發(fā)現(xiàn),如果改變一下,像這樣:
多么像無奈的友情或者愛情呀,從肥到瘦,曾經(jīng)的熱情像火焰般點(diǎn)燃,到最后只留被灼傷的自我。
就這樣吧!
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。