MATLAB函數繪圖-fplot3

fplot3:三維參數化曲線繪圖函數
1.繪制三維參數化線條
x=sin(t)
y=cos(t)
z=t

(在默認參數范圍 [-5 5] 內。)

xt = @(t) sin(t);
yt = @(t) cos(t);
zt = @(t) t;
fplot3(xt,yt,zt)

MATLAB函數繪圖-fplot3的圖1

2.指定參數范圍
繪制參數化線條

x=e^(?t/10)*sin(5t)
y=e^(?t/10)*cos(5t)
z=t

(通過指定 fplot3 的第四個輸入實參,在形參范圍 [-10 10] 內繪制)。

xt = @(t) exp(-t/10).*sin(5*t);
yt = @(t) exp(-t/10).*cos(5*t);
zt = @(t) t;
fplot3(xt,yt,zt,[-10 10])

MATLAB函數繪圖-fplot3的圖2

3.指定線條屬性并顯示標記
在參數的不同區間,將同一條三維參數化曲線繪制三次。對于第一個區間,使用 2 磅的線寬。對于第二個,指定帶有圓形標記的紅色虛線線型。對于第三個,指定帶有星號標記的青藍色點劃線線型。

fplot3(@(t)sin(t), @(t)cos(t), @(t)t, [0 2*pi], ...'LineWidth', 2)
hold on
fplot3(@(t)sin(t), @(t)cos(t), @(t)t, [2*pi 4*pi], '--...or')
fplot3(@(t)sin(t), @(t)cos(t), @(t)t, [4*pi 6*pi], ...'-.*c')
hold off

MATLAB函數繪圖-fplot3的圖3

4.在相同坐標區中繪制多個線條

使用 hold on 在相同的坐標區中繪制多個線條。

fplot3(@(t)t, @(t)t, @(t)t)

hold on

fplot3(@(t)-t, @(t)t, @(t)-t)

hold off

MATLAB函數繪圖-fplot3的圖4

5.創建后修改三維參數化線條

繪制參數化線條

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)

MATLAB函數繪圖-fplot3的圖5

fp = 

  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';

MATLAB函數繪圖-fplot3的圖6

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

MATLAB函數繪圖-fplot3的圖7

使用 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'};

MATLAB函數繪圖-fplot3的圖8

【免責聲明】本文檔部分內容摘自網絡平臺,版權歸原作者所有,僅用于技術分享與交流,非商業用途!若有涉及版權等請告知,將及時修訂刪除,謝謝大家的關注!
登錄后免費查看全文
立即登錄
App下載
技術鄰APP
工程師必備
  • 項目客服
  • 培訓客服
  • 平臺客服

TOP

12
4
5