当前位置:网站首页>Matlab example: two expressions of step function
Matlab example: two expressions of step function
2022-07-06 15:32:00 【Bitter tea seeds】
List of articles
Preface
The step function is MATLAB There are two kinds of calling functions :
heaviside() function 、stepfun() function
Now let's take a look at the difference and usage between them .
One 、heaviside() function
1.heaviside() Function introduction
Here's the picture MATLAB The introduction in the dictionary , Can see heaviside Function call is very simple :H = heaviside(x); also heaviside It's a Discontinuous functions . It returns 0 Express x < 0, return 1/2 Express x = 0, return 1 Express x > 0.
Simple painting heaviside
syms x
fplot(heaviside(x), [-2, 2])
2.heaviside() example
The code is as follows
>> T=0.01;% step
>> t1=0;t2=3;t3=-2;t4=2;% Coordinate parameters
>> t5=t1:T:t2;%t5 Value range ;
>> t6=t3:T:t4;%t6 Value range ;
>> f1=2*exp(-2*t5);% Exponential function
>> f2=3*(heaviside(t6-1)-heaviside(t6-2));% Gate function
>> [y]=conv(f1,f2);% Set convolution as matrix
>> y=y*T;t=(t1+t3):T:(t2+t4);% The value range of convolution
>> subplot(3,1,1);plot(t5,f1,'r');axis([(t1+t3),(t2+t4),min(f1),max(f1)+0.5]);% Set axis
>> ylabel('f1(t) The index curve ');line([0,0],[0,2.5]);title(' Signal convolution ');
>> subplot(3,1,2);plot(t6,f2);axis([(t1+t3),(t2+t4),min(f2),max(f2)+0.5]);
>> ylabel('f2(t) Gate function ');
>> subplot(3,1,3);plot(t,y,'m');axis([(t1+t3),(t2+t4),min(y),max(y)+0.5]);ylabel('y(t) Convolution synthesis curve ');
Two 、stepfun() function
1.stepfun() Function introduction
stepfun Function call stepfun(x,y) among x Represents abscissa and y Represents the ordinate . among x It must be an ascending vector , y Length ratio of x Big 1.
A simple example
The code is as follows ( Example ):
>> b=-5:0.01:20;% Define time samples
>> b0=0;% The moment when the signal changes
>> ut=stepfun(b,b0);% Generate unit step signal
>> plot(b,ut),axis([-5,20,-2.5,10])% Axis
2.stepfun() example
The code is as follows ( Example ):
>> T=0.01;% step
>> t1=0;t2=3;t3=-2;t4=2;% Coordinate parameters
>> t5=t1:T:t2;%t5 Value range ;
>> t6=t3:T:t4;%t6 Value range ;
>> f1=2*exp(-2*t5);% Exponential function
>> f2=3*(stepfun(t6,-1)-stepfun(t6,2));% Gate function
>> [y]=conv(f1,f2);% Set convolution as matrix
>> y=y*T;t=(t1+t3):T:(t2+t4);% The value range of convolution
>> subplot(3,1,1);plot(t5,f1,'r');axis([(t1+t3),(t2+t4),min(f1),max(f1)+0.5]);% Set axis
>> ylabel('f1(t) The index curve ');line([0,0],[0,2.5]);title(' Signal convolution ');
>> subplot(3,1,2);plot(t6,f2);axis([(t1+t3),(t2+t4),min(f2),max(f2)+0.5]);
>> ylabel('f2(t) Gate function ');
>> subplot(3,1,3);plot(t,y,'m');axis([(t1+t3),(t2+t4),min(y),max(y)+0.5]);ylabel('y(t) Convolution synthesis curve ');
summary
That's what we're going to talk about today , This article only briefly introduces heaviside() function 、stepfun() function Use , and MATLAB Provides a large number of functions and methods that enable us to process data quickly and conveniently , Are waiting for our exploration and use .
Xiao Liu's sadness urges daily , Finally, it's going to change
Xiao Liu arrived at the boss' office early in the morning , To put it mildly :“ Boss, I've been working hard these two days , Working overtime all the time , Look at this overtime pay ……”
“ What overtime pay ? I don't know what you're talking about ? The company is training you , What overtime pay do you want ?”
The boss looked at Xiao Liu with disdain on his face .
Xiao Liu blushed , I can't say a word for a long time ; The boss looked at Xiao Liu , Roar :“ Don't go to work soon , Delayed project submission , I'll deduct your salary !”
Xiao Liu walked back to the station , At this time, a message suddenly came from the mobile phone : 100000 monthly salary , Cardiac connection ……
边栏推荐
- [C language] twenty two steps to understand the function stack frame (pressing the stack, passing parameters, returning, bouncing the stack)
- Video scrolling subtitle addition, easy to make with this technique
- Eigen User Guide (Introduction)
- Interview answering skills for software testing
- 学习记录:如何进行PWM 输出
- China medical check valve market trend report, technical dynamic innovation and market forecast
- ucore lab 6
- What to do when programmers don't modify bugs? I teach you
- Stm32 dossiers d'apprentissage: saisie des applications
- Pedestrian re identification (Reid) - Overview
猜你喜欢
LeetCode#19. Delete the penultimate node of the linked list
Eslint--- error: newline required at end of file but not found (EOL last) solution
软件测试面试回答技巧
ucore Lab 1 系统软件启动过程
How to become a good software tester? A secret that most people don't know
csapp shell lab
The minimum number of operations to convert strings in leetcode simple problem
[C language] twenty two steps to understand the function stack frame (pressing the stack, passing parameters, returning, bouncing the stack)
学习记录:使用STM32外部输入中断
学习记录:串口通信和遇到的错误解决方法
随机推荐
Stm32 dossiers d'apprentissage: saisie des applications
Take you to use wxpy to create your own chat robot (plus wechat interface basic data visualization)
Mysql database (III) advanced data query statement
接口测试面试题及参考答案,轻松拿捏面试官
Research Report on medical anesthesia machine industry - market status analysis and development prospect prediction
Es6--- two methods of capturing promise status as failed
Should wildcard import be avoided- Should wildcard import be avoided?
CSAPP Shell Lab 实验报告
Medical colposcope Industry Research Report - market status analysis and development prospect forecast
MySQL数据库(二)DML数据操作语句和基本的DQL语句
Sorting odd and even subscripts respectively for leetcode simple problem
Jupyter installation and use tutorial
ucorelab4
The wechat red envelope cover designed by the object is free! 16888
What are the commonly used SQL statements in software testing?
UCORE lab1 system software startup process experimental report
STM32 learning record: input capture application
LeetCode#19. Delete the penultimate node of the linked list
How to rename multiple folders and add unified new content to folder names
FSM和i2c实验报告