当前位置:网站首页>MATLAB实例:阶跃函数的两种表达方式
MATLAB实例:阶跃函数的两种表达方式
2022-07-06 09:25:00 【Bitter tea seeds】
文章目录
前言
阶跃函数在MATLAB中有两种调用函数:
heaviside()函数、stepfun()函数
下面我们就来看看它俩的区别和用法。
一、heaviside()函数
1.heaviside()函数的介绍
如下图MATLAB字典上的介绍,可以看见heaviside函数的调用很简单:H = heaviside(x);并且heaviside是一个不连续的函数。它返回 0 表示 x < 0,返回 1/2 表示 x = 0,返回 1 表示 x > 0。
简单画heaviside
syms x
fplot(heaviside(x), [-2, 2])

2.heaviside()实例
代码如下所示
>> T=0.01;%步长
>> t1=0;t2=3;t3=-2;t4=2;%坐标参数
>> t5=t1:T:t2;%t5取值范围;
>> t6=t3:T:t4;%t6取值范围;
>> f1=2*exp(-2*t5);%指数函数
>> f2=3*(heaviside(t6-1)-heaviside(t6-2));%门函数
>> [y]=conv(f1,f2);%将卷积设为矩阵
>> y=y*T;t=(t1+t3):T:(t2+t4);%卷积的取值范围
>> subplot(3,1,1);plot(t5,f1,'r');axis([(t1+t3),(t2+t4),min(f1),max(f1)+0.5]);%设置坐标轴
>> ylabel('f1(t)指数曲线');line([0,0],[0,2.5]);title('信号卷积');
>> subplot(3,1,2);plot(t6,f2);axis([(t1+t3),(t2+t4),min(f2),max(f2)+0.5]);
>> ylabel('f2(t)门函数');
>> subplot(3,1,3);plot(t,y,'m');axis([(t1+t3),(t2+t4),min(y),max(y)+0.5]);ylabel('y(t)卷积合成曲线');

二、stepfun()函数
1.stepfun()函数的介绍
stepfun函数的调用stepfun(x,y)其中x代表横坐标和y代表纵坐标. 其中x必须是一个升序的向量, y的长度比x大1。
简单举例
代码如下(示例):
>> b=-5:0.01:20;%定义时间样本
>> b0=0;%信号发生突变的时刻
>> ut=stepfun(b,b0);%产生单位的阶跃信号
>> plot(b,ut),axis([-5,20,-2.5,10])%坐标轴

2.stepfun()实例
代码如下(示例):
>> T=0.01;%步长
>> t1=0;t2=3;t3=-2;t4=2;%坐标参数
>> t5=t1:T:t2;%t5取值范围;
>> t6=t3:T:t4;%t6取值范围;
>> f1=2*exp(-2*t5);%指数函数
>> f2=3*(stepfun(t6,-1)-stepfun(t6,2));%门函数
>> [y]=conv(f1,f2);%将卷积设为矩阵
>> y=y*T;t=(t1+t3):T:(t2+t4);%卷积的取值范围
>> subplot(3,1,1);plot(t5,f1,'r');axis([(t1+t3),(t2+t4),min(f1),max(f1)+0.5]);%设置坐标轴
>> ylabel('f1(t)指数曲线');line([0,0],[0,2.5]);title('信号卷积');
>> subplot(3,1,2);plot(t6,f2);axis([(t1+t3),(t2+t4),min(f2),max(f2)+0.5]);
>> ylabel('f2(t)门函数');
>> subplot(3,1,3);plot(t,y,'m');axis([(t1+t3),(t2+t4),min(y),max(y)+0.5]);ylabel('y(t)卷积合成曲线');

总结
以上就是今天要讲的内容,本文仅仅简单介绍了heaviside()函数、stepfun()函数的使用,而MATLAB提供了大量能使我们快速便捷地处理数据的函数和方法,都等待着我们的探索和使用。
小刘的悲催日常,终于要转运了
小刘一大早就到老板的办公室,委婉的说:“老板你看我这两天挺辛苦的,一直在加班,你看这个加班费……”
“什么加班费?我不知道你说的什么?公司里培养着你,你要什么加班费?”
老板一脸不屑的瞅着小刘。
小刘涨红了脸,半天说不出一个字来;老板看着小刘,吼道:“还不快去工作,延误了项目提交,我扣你工资!”
小刘走回了工位上,这时候手机突然蹦传来一条消息:十万月薪,心动联系……
边栏推荐
- 转行软件测试必需要知道的知识
- 全网最详细的postman接口测试教程,一篇文章满足你
- UCORE lab8 file system experiment report
- FSM和i2c实验报告
- 遇到程序员不修改bug时怎么办?我教你
- LeetCode#62. Different paths
- Pedestrian re identification (Reid) - data set description market-1501
- Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
- CSAPP Shell Lab 实验报告
- STM32学习记录:输入捕获应用
猜你喜欢

想跳槽?面试软件测试需要掌握的7个技能你知道吗

Report on the double computer experiment of scoring system based on 485 bus

ucore lab 6

UCORE lab5 user process management experiment report

UCORE LaB6 scheduler experiment report

CSAPP shell lab experiment report
What is "test paper test" in software testing requirements analysis

Crawler series of learning while tapping (3): URL de duplication strategy and Implementation

Brief introduction to libevent
What are the software testing methods? Show you something different
随机推荐
Portapack application development tutorial (XVII) nRF24L01 launch B
A method and implementation of using VSTO to prohibit excel cell editing
What are the software testing methods? Show you something different
Investment operation steps
Programmers, how to avoid invalid meetings?
Eslint--- error: newline required at end of file but not found (EOL last) solution
软件测试有哪些常用的SQL语句?
Lab 8 文件系统
FSM和i2c实验报告
The minimum number of operations to convert strings in leetcode simple problem
JS --- BOM details of JS (V)
接口测试面试题及参考答案,轻松拿捏面试官
LeetCode#237. Delete nodes in the linked list
LeetCode#53. Maximum subarray sum
12306: mom, don't worry about me getting the ticket any more (1)
What are the business processes and differences of the three basic business modes of Vos: direct dial, callback and semi direct dial?
软件测试Bug报告怎么写?
Emqtt distribution cluster and node bridge construction
Es6---es6 content details
JS --- detailed explanation of JS DOM (IV)