永发信息网

MATLAB中plot函数和line函数作用有区别吗?

答案:3  悬赏:50  手机版
解决时间 2021-01-27 06:43
MATLAB中plot函数和line函数作用有区别吗?
最佳答案
两个函数的格式不同:
plot(X,Y,S); % X,Y为坐标,画出一个点,S为其它属性(颜色,点的大小等)。
line([X1 X2],[Y1 Y2],S); %点A(X1,Y1)和点B(X2 Y2)之间画一条直线,S为其它属性(颜色,线的粗细等)。
详细资料可以在matlab主面板里输入 "help plot" 和 "help line".
全部回答
前者画图,后者只画线。
PLOT Linear plot.
PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, length(Y)
disconnected points are plotted.

PLOT(Y) plots the columns of Y versus their index.
If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)).
In all other uses of PLOT, the imaginary part is ignored.

Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:

b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram

For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.

PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X's and Y's are vectors or matrices
and the S's are strings.

For example, PLOT(X,Y,'y-',X,Y,'go') plots the data twice, with a
solid yellow line interpolating green circles at the data points.

The PLOT command, if no color is specified, makes automatic use of
the colors specified by the axes ColorOrder property. The default
ColorOrder is listed in the table above for color systems where the
default is blue for one line, and for multiple lines, to cycle
through the first six colors in the table. For monochrome systems,
PLOT cycles over the axes LineStyleOrder property.

If you do not specify a marker type, PLOT uses no marker.
If you do not specify a line style, PLOT uses a solid line.

PLOT(AX,...) plots into the axes with handle AX.

PLOT returns a column vector of handles to lineseries objects, one
handle per plotted line.

The X,Y pairs, or X,Y,S triples, can be followed by
parameter/value pairs to specify additional properties
of the lines. For example, PLOT(X,Y,'LineWidth',2,'Color',[.6 0 0])
will create a plot with a dark red line width of 2 points.

Backwards compatibility
PLOT('v6',...) creates line objects instead of lineseries
objects for compatibility with MATLAB 6.5 and earlier.
LINE Create line.
LINE(X,Y) adds the line in vectors X and Y to the current axes.
If X and Y are matrices the same size, one line per column is added.
LINE(X,Y,Z) creates lines in 3-D coordinates.

LINE returns a column vector of handles to LINE objects,
one handle per line. LINEs are children of AXES objects.

The X,Y pair (X,Y,Z triple for 3-D) can be followed by
parameter/value pairs to specify additional properties of the lines.
The X,Y pair (X,Y,Z triple for 3-D) can be omitted entirely, and
all properties specified using parameter/value pairs.

Execute GET(H), where H is a line handle, to see a list of line
object properties and their current values. Execute SET(H) to see a
list of line object properties and legal property values.
1.private与子函数:
子函数只能在主函数内容中调用,在函数外无法使用
function MainFunction
%主函数内容
function SubFunction1
%子函数内容
end
function SubFunction2
%子函数内容
end
function SubFunction3
%子函数内容
end
end
private函数是matlab软件中广泛使用的一种技术,其作用是限定某一些函数(private文件夹内)只能被令一些函数(private文件夹所在文件夹中的函数)使用,其他函数不能使用,这样的话就可以避免一些无用(因为一般的matlab函数是全局可见的,而private函数只能被private文件夹所在文件夹中的函数调用。
2.ezplot和fplot
ezplot是easy plot的简称,意思就是简化画图,只需给出函数体而无需变量范围,例如想画个圆,用ezplot就很方便:
syms x y
ezplot('x^2+y^2=1',[-1.5 1.5],[-1 1])
fplot的意思是function plot,就是画某一函数的曲线。顾名思义,若要画一条函数的曲线,只要给出函数名和自变量范围即可,例子如下:
fplot('sin',[-2 2])
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
这样的代码为什么不对!!!!
广东和浙江的高中教材一样吗?
下图为国际主要粮食价格与我国同期市场价格比
53缩小到原数的()是0.53
大而无收什么意思
家用电视机正常工作时的电流最接近(  )
为什么要积极承担国际责任和义务
有关平屋顶的保温方案,下列()传热阻最小。A.
旧矩的意思是什么啊?知道的请说下!
十条直线相交,最多有多少个交点?若只要求31个
请以日出为内容写一个句子要求同时使用比喻与
如何判别现代房子是东四宅还是西四宅?
百结愁肠的意思是什么啊?知道的请说下!
直径920MM*12M*10MM的圆管有多重?圆管重量怎
摔不破的桶是用什么材料做的 对人有没有害
推荐资讯
裂石流云的意思是什么啊?知道的请说下!
被黑洞撕裂会是什么感觉
【鹦鹉英语怎么读】“鹦鹉”英文怎么读?怎么
十年前的老同学,十年没见面了,我想追她,可
刚才我的小米3手机,卡一下屛,就就开不开机
盐呆子的意思是什么啊?知道的请说下!
15kw的变频应该用多少平方的电线
下列处理哪项是错误的A.吸氧B.静脉抗生素C.高
怎样才能提高成绩 我想考上我理想的高
我在寻找一幅画 7.28在P站无意打开,绝得很好
燃气热水器防止泄漏在原有的烟管上再套根烟管
max3490全双工收发器属于模拟集成电路还是数
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?