Matlab fplot函数详解

        Matlab之fplot函数详解

功能:绘制表达式或函数
语法: fplot(f)
fplot(f,xinterval)
fplot(funx,funy)
fplot(funx,funy,tinterval)
fplot(__,LineSpecial)
fplot(_,name,value)
fplot(ax,_)
Fp = fplot(_)
[x y] = fplot(__)
说明:
1.fplot(f)在默认区间-5 5绘制由函数y = f(x)绘制的曲线
//例:fplot(@(x)(sin(x)) %@(x)(sin(x))为匿名函数
Matlab fplot函数详解_第1张图片
2.fplot(f,xinterval)
指定区间绘制函数
例:绘制分段函数f(x) =
e^x (-3,0) cosx (0,3)
Trial>> fplot(@(x)exp(x),[-3 0],’b’);
Trial>> hold on;
Trial>> fplot(@(x)cos(x),[0 3],’b’);
Matlab fplot函数详解_第2张图片
3.fplot(funx,funy)绘制参数曲线
例: x=cos(3t) y=sin(2t)
Trial>> xt = @(t)cos(3*t);
Trial>> yt = @(t)sin(2*t);
Trial>> fplot(xt,yt);
Matlab fplot函数详解_第3张图片
4.fplot(funx,funy,[tmin tmax]
接3
fplot(xt,yt,[0 pi]);
Matlab fplot函数详解_第4张图片
5.fplot(…..,LineSpecial)指定线型,标记符号和线条颜色,例如’-r’绘制一条红色线条
6.fplot(….,name,value)使用一个或多个名称—值对组参数指定线条参数
例如’LineWidth’,2指定2磅的线宽
fplot(@(x)sin(x+pi/5),’LineWidth’,2);
hold on;
fplot(@(x)sin(x-pi/5),’–or’);
fplot(@(x)sin(x),’-.*c’);
hold off;
Matlab fplot函数详解_第5张图片
7.fplot(ax,….)将图形绘制到ax指定坐标轴上,而不是当前坐标轴(gca)中
8.fp = fplot(…..)返回函数线条或参数函数线条对象(取决于具体输入)使用fp查看和修改线条属性
fp = fplot(@(x)sin(x));
fp.LineStyle = ‘:’;
fp.Color = ‘r’;
fp.Marker = ‘x’;
fp.MarkerEdgeColor = ‘b’;
Matlab fplot函数详解_第6张图片
总结:
例:绘制sin(x)图像[0,2*pi]
fp = fplot(@(x)sin(x),[0 2*pi]);
grid on;
title(‘sin(x)图像 from 0 to 2*pi’);
xlabel(‘x轴’);
ylabel(‘y轴’);
fp.LineStyle = ‘:’;
fp.Color = ‘r’;
fp.Marker = ‘x’;
fp.MarkerEdgeColor = ‘b’;
ax = gca;
ax.XTick = 0:pi/2:2*pi;
ax.XTickLabel = {‘0’,’pi/2’,’pi’,’3*pi/2’,’2*pi’};
Matlab fplot函数详解_第7张图片

你可能感兴趣的:(matlab,fplot,函数,Matlab)