fplot
阴谋符号表达or function
句法
描述
fplot(
plotsF
,,,,[Xmin Xmax]
)F
超过the interval[Xmin Xmax]
。
fplot(
plotsXT=X((t)and是=y((t)超过指定范围XT
,,,,是
,,,,[tmin tmax]
)[tmin tmax]
。
fplot(___,,,,
使用一个或多个指定行属性名称,价值
)名称,价值
配对参数。将此选项与上一个语法中的任何输入参数组合一起使用。名称,价值
pair settings apply to all the lines plotted. To set options for individual lines, use the objects returned byfplot
。
fplot(
图到指定的轴斧头
,,,,___)斧头
而不是当前轴GCA
。
根据图的类型返回函数线对象或参数化行对象。使用对象查询和修改特定行的属性。有关详细信息,请参阅FunctionLine PropertiesandParameterizedFunctionLine Properties。fp
=fplot(___)
例子
阴谋symbolic Function
阴谋the symbolic function
超过默认范围[-5 5]
。
符号F(x)f(x)= cos(x);fplot(f)
阴谋Parametric Curve
阴谋the parametric curve and 。
符号tX=cos(3*t); y = sin(2*t); fplot(x,y)
specify Plotting Interval
阴谋
超过
通过将绘图间隔指定为第二个输入fplot
。
符号Xfplot(罪(x),,,,[[-pi/2 pi/2])
在同一图上绘制多行
您可以通过将输入作为向量或使用来绘制多行hold on
连续绘制同一图。如果指定LinesPec
and Name-Value arguments, they apply to all lines. To set options for individual plots, use the function handles returned byfplot
。
Divide a figure into two subplots using子图
。On the first subplot, plot
and
using vector input. On the second subplot, plot
and
usinghold on
。
符号X子图(2,1,1)fplot([[sin(x)cos(x)])标题(“使用向量输入的多行”)子图(2,1,2)fplot(sin(x))保持onfplot(cos(x))标题('Multiple Lines Using hold on Command')holdoff
更改行属性和显示标记
在每条线之间绘制三个正弦曲线。对于第一行,使用一条线宽2
。第二个,指定带有圆形标记的虚线红线样式。对于第三个,请指定带有星号标记的青色仪表板线样式。显示传奇。
符号Xfplot(sin(x+pi/5),'行宽',2)保持onfplot(罪((X-pi/5),' - 或者')fplot(sin(x),'-.*c') 传奇('节目',,,,'Location',,,,'最好的')holdoff
情节的控制分辨率
通过使用MeshDensity
option. IncreasingMeshDensity
可以使更光滑,更准确的图可以提高绘图速度。
Divide a figure into two by using子图
。在第一个子图中,从x = 2.1
tox = 2.15
。该图的分辨率太低,无法检测步骤函数。通过增加此问题MeshDensity
to39
在第二个子图中。该图现在检测到步骤函数,并通过增加MeshDensity
you increased the plot's resolution.
符号XstepFn = rectangularPulse(2.1, 2.15, x); subplot(2,1,1) fplot(stepFn); title('Default MeshDensity = 23')子图(2,1,2)FPLOT(Stepfn,“网状密度”,39);标题('网格密度= 39')
Modify Plot After Creation
阴谋罪(x)
。指定输出以进行fplot
返回绘图对象。
符号Xh = fplot(sin(x))
h = FunctionLine with properties: Function: sin(x) Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Show all properties
通过使用点符号设置属性,将默认蓝线更改为虚线的红线。同样,添加'X'
markers and set the marker color to blue.
h.linestyle =' - ';h.Color ='r';H.Marker ='X';H.MarkeredGecolor ='b';
Add Title and Axis Labels and Format Ticks
为了
从
to
, 阴谋
。Add a title and axis labels. Create the x-axis ticks by spanning the x-axis limits at intervals ofpi/2
。通过使用XTICK
财产。通过使用arrayfun
申请德州人
tos
。通过使用Xticklabel
财产。
To use LaTeX in plots, see乳胶
。
符号Xfplot(罪(x),,,,[[-2*pi 2*pi]) gridon标题('sin(x)从-2 \ pi到2 \ pi')Xlabel('X')ylabel('y')ax = gca;s = sym(ax.xlim(1):pi/2:ax.xlim(2));ax.xtick = double(s);ax.xticklabel = arrayfun(@texlabel,s,'UniformOutput',,,,False);
重新评估Zoom
当您放大情节时,fplot
自动重新评估图。这种重新评估在缩放下揭示了较小尺度的隐藏细节。
阴谋X^3*sin(1/x)
为了-2
-0.02
zoom
并使用绘制
。由于重新评估Zoom,fplot
揭示较小的细节。重复6次缩放以查看较小规模的细节。要播放动画,请单击图像。
符号Xfplot(X^3*sin(1/x)); axis([-2 2 -0.02 0.02]);为了i = 1:6变焦(1.7)暂停(0.5)结尾
Create Animations
通过使用Function
,,,,XFunction
,,,,and函数
属性,然后使用绘制
更新图。要导出到GIF,请参阅一世mwrite
。
By varying the variable一世从0。1to 3, animate the parametric curve
要播放动画,请单击图像。
符号tfp = fplot(t,t);轴([ - 15 15 -15 15])为了i = 0.1:0.05:3 fp.xfunction = i。*t。*sin(i*t);fp.yfunction = i。*t。*cos(i*t);绘制结尾
输入参数
输出参数
尖端
如果
fplot
检测到有限数量的不连续性F
, 然后fplot
扩展范围以显示它们。