MATLAB函數繪圖-fplot3
4.在相同坐標區中繪制多個線條
使用 hold on 在相同的坐標區中繪制多個線條。
fplot3(@(t)t, @(t)t, @(t)t)
hold on
fplot3(@(t)-t, @(t)t, @(t)-t)
hold off
繪制參數化線條
x=e^(?|t|/10)*sin(5*|t|)
y=e^(?|t|/10)*cos(5*|t|)
z=t.
將參數化函數行對象指定給變量。
xt = @(t)exp(-abs(t)/10).*sin(5*abs(t));
yt = @(t)exp(-abs(t)/10).*cos(5*abs(t));
zt = @(t)t;
fp = fplot3(xt,yt,zt)
ParameterizedFunctionLine with properties:
XFunction: @(t)exp(-abs(t)/10).*sin(5*abs(t))
YFunction: @(t)exp(-abs(t)/10).*cos(5*abs(t))
ZFunction: @(t)t
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Show all properties
將參數值范圍更改為 [-10 10],并將線條顏色更改為紅色。
fp.TRange = [-10 10];
fp.Color = 'r';
6.添加標題和軸標簽以及格式化刻度
為從 ?2π 到 2π 范圍內的 t 值繪制參數化線條
x=t
y=t/2
z=sin(6t).
添加標題、x 軸標簽和 y 軸標簽。此外,還可以更改坐標區視圖并顯示坐標區框輪廓。
xt = @(t)t;
yt = @(t)t/2;
zt = @(t)sin(6*t);
fplot3(xt,yt,zt,[-2*pi 2*pi],'MeshDensity',30,'LineWidth',1);
title('x=t, y=t/2, z=sin(6t) for -2\pi<t<2\pi')
xlabel('x');
ylabel('y');
view(52.5,30)
box on
使用 gca 訪問坐標區對象。使用坐標區對象的 XTick 和 XTickLabel 屬性指定 x 軸刻度值和關聯的標簽。按照同樣的方式指定 y 軸刻度值和關聯的標簽。
ax = gca;
ax.XTick = -2*pi:pi/2:2*pi;
ax.XTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0','\pi/2','\pi','3\pi/2','2\pi'};
ax.YTick = -pi:pi/2:pi;
ax.YTickLabel = {'-\pi','-\pi/2','0','\pi/2','\pi'};
工程師必備
- 項目客服
- 培訓客服
- 平臺客服
TOP




















