当前位置:网站首页>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提供了大量能使我们快速便捷地处理数据的函数和方法,都等待着我们的探索和使用。
小刘的悲催日常,终于要转运了
小刘一大早就到老板的办公室,委婉的说:“老板你看我这两天挺辛苦的,一直在加班,你看这个加班费……”
“什么加班费?我不知道你说的什么?公司里培养着你,你要什么加班费?”
老板一脸不屑的瞅着小刘。
小刘涨红了脸,半天说不出一个字来;老板看着小刘,吼道:“还不快去工作,延误了项目提交,我扣你工资!”
小刘走回了工位上,这时候手机突然蹦传来一条消息:十万月薪,心动联系……
边栏推荐
- Video scrolling subtitle addition, easy to make with this technique
- Réponses aux devoirs du csapp 7 8 9
- Mysql database (III) advanced data query statement
- 線程及線程池
- What are the software testing methods? Show you something different
- Stm32 dossiers d'apprentissage: saisie des applications
- Jupyter installation and use tutorial
- Your wechat nickname may be betraying you
- Mysql database (V) views, stored procedures and triggers
- Dlib detects blink times based on video stream
猜你喜欢
转行软件测试必需要知道的知识
Nest and merge new videos, and preset new video titles
ucore Lab 1 系统软件启动过程
China's county life record: go upstairs to the Internet, go downstairs' code the Great Wall '
Daily code 300 lines learning notes day 9
ucore lab5用户进程管理 实验报告
FSM和i2c实验报告
What are the commonly used SQL statements in software testing?
12306: mom, don't worry about me getting the ticket any more (1)
ucorelab4
随机推荐
Report on the double computer experiment of scoring system based on 485 bus
想跳槽?面试软件测试需要掌握的7个技能你知道吗
ucorelab3
Knowledge that you need to know when changing to software testing
自动化测试中敏捷测试怎么做?
JS --- BOM details of JS (V)
Interview answering skills for software testing
Introduction to safety testing
ucore lab5用户进程管理 实验报告
ucore lab8 文件系统 实验报告
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
[C language] twenty two steps to understand the function stack frame (pressing the stack, passing parameters, returning, bouncing the stack)
Crawler series of learning while tapping (3): URL de duplication strategy and Implementation
软件测试工作太忙没时间学习怎么办?
ucore lab 2
ucore lab1 系统软件启动过程 实验报告
ucore lab7 同步互斥 实验报告
Mysql database (II) DML data operation statements and basic DQL statements
Flex --- detailed explanation of flex layout attributes
Eigen User Guide (Introduction)