当前位置:网站首页>Detailed explanation of MATLAB drawing function fplot
Detailed explanation of MATLAB drawing function fplot
2022-08-02 15:33:00 【Yang Laotou Soft Worker】
Detailed explanation of MATLAB drawing function fplot
1. Basic syntax of fplot
Unlike plot, fplot is mainly used to directly draw function curves according to the function expression and the interval to which the independent variables belong.Therefore, when the function expression is known, it is relatively simple to use fplot to draw the function curve.
Its basic syntax is as follows:
1) fplot( f, xinterval, s )Where f is the expression of the independent variable in the function, xinterval is the value range of the independent variable, and s represents the attribute of the primitive, which is similar to the primitive attribute in the plot.When xinterval is default, the default interval of the argument is [-5, 5].
2) fplot( fx, fy, tinterval, s )This form is mainly used to draw function curves represented by parametric equations.Where fx and fy represent the expressions of x and y with respect to parameter t, respectively, tinterval is the value range of parameter t, and s represents the attribute of the primitive.
3) fplot( @(var) f(var), xinterval, s )Where @(var) is to declare var as an independent variable (the identifier can be given as needed), f(var) is a specific function expression, xinterval is the value range of the independent variable, and s represents the value of the primitiveAttributes.
4) fplot( @(t)fx(t), @(t) fy(t), tinterval, s )Where @(t) is to declare t as a parameter (the identifier can be given as needed), fx(t) and fy(t) are the expressions of the abscissa and ordinate of the specific parameter equation, and tinterval is the parameterThe value range of t, and s represents the attribute of the primitive.
Note: Usage 1) and 2) will have a warning in the new version.3) and 4) are standard usage in the new version.
Second, the specific example
Example 1. Draw y=sin(x) curve graph.
% sample code (1)clear allclcfplot( 'sin(x)' ) % only function expressions are given%run result
% sample code (2)clear allclcfplot( 'sin(x)',[ -pi, pi ], 'ro' )xlabel( 'x' );ylabel( 'sin(x)' );%run result
% sample code (3)clear allclcfplot( @(x)sin(x),[ -pi, pi ] )xlabel( 'x' );ylabel( 'sin(x)' );%Running results
Example 2. In the sameOne window draws sine and cosine curves in one cycle
% sample codeclear allclcfplot( @(x)sin(x),[ -pi, pi ], 'r-.' )hold onfplot( @(x)cos(x),[ -pi, pi ], 'b--' )xlabel( 'x' );ylabel( 'y' );legend( 'y=sin(x)', 'y=cos(x)' );%run result
Example 3. Drawing a unit circle
% sample codeclear allclcfplot( @(t)sin(t), @(t)cos(t),[ -pi, pi ] ) % solid line unit circlehold onfplot( @(t)sin(t), @(t)cos(t),[ -pi, pi ], 'ro' ) % unit circle scatterplotxlabel( 'x' );ylabel( 'y' );title( 'Unit Circle' );axis equalaxis( [ -1.5, 1.5, -1.5, 1.5 ] );%run result
Example 4. Plot piecewise function curve
% sample codeclear allclcfplot( @(x)(7-x).^2/4,[1, 5 ], 'r' )hold onfplot( @(x)x-4,[5, 10 ], 'r' )fplot( @(x)16-x,[10, 15 ], 'r' )fplot( @(x)(x-13).^2/4,[15, 19 ], 'r' )xlabel( 'x' );ylabel( 'y' );title( 'Piecewise Function Curve' );axis( [ 0, 20, 0, 10 ] );%run result
边栏推荐
- 推开机电的大门《电路》(一):电压,电流,参考方向
- What should I do if I install a solid-state drive in Win10 and still have obvious lags?
- Codeforces Round #605 (Div. 3)
- What should I do if Windows 10 cannot connect to the printer?Solutions for not using the printer
- Redis常见面试题
- IPV4和IPV6是什么?
- Mysql连接错误解决
- flink+sklearn——使用jpmml实现flink上的机器学习模型部署
- 二叉树创建之层次法入门详解
- How to reinstall Win7 system with U disk?How to reinstall win7 using u disk?
猜你喜欢

Win10安装了固态硬盘还是有明显卡顿怎么办?

软件测试基础知识(背)

网络安全抓包

Lightweight AlphaPose

Based on the least squares linear regression equation coefficient estimation

Win7 encounters an error and cannot boot into the desktop normally, how to solve it?

二叉树创建之层次法入门详解

What should I do if the Win10 system sets the application identity to automatically prompt for access denied?

Win10上帝模式干嘛的?Win10怎么开启上帝模式?
![[System Design and Implementation] Flink-based distracted driving prediction and data analysis system](/img/f0/23ac631b6eb9b794224d8ae78e6523.png)
[System Design and Implementation] Flink-based distracted driving prediction and data analysis system
随机推荐
Yolov5 official code reading - prior to transmission
Spark及相关生态组件安装配置——快速回忆
What are IPV4 and IPV6?
Win10电脑需要安装杀毒软件吗?
Mysql lock
MATLAB绘图函数ezplot入门详解
关于c语言的调试技巧
求解斐波那契数列的若干方法
发布模块到npm应该怎么操作?及错误问题解决方案
Mapreduce环境详细搭建和案例实现
将SSE指令转换为ARM NEON指令
Win10 cannot directly use photo viewer to open the picture
Win11 computer off for a period of time without operating network how to solve
Network Security Packet Capture
Codeforces Round #624 (Div. 3)
Installation and configuration of Spark and related ecological components - quick recall
Detailed introduction to drawing complex surfaces using the plot_surface command
二叉树的遍历:递归法/ 迭代法/ 统一迭代法(强QAQ)
Knapsack Problem - Dynamic Programming - Theory
Failed to install using npx -p @storybook/cli sb init, build a dedicated storybook by hand