xlim用法matlab,MATLAB之xlim 、 ylim 、zlim的简单介绍
EDA365歡迎您登錄!
您需要 登錄 才可以下載或查看,沒有帳號?注冊
x
2 t9 e% ~6 N& L- M
ylim" {1 I6 t9 a??]. {9 z
設置或查詢 y 軸限制1 M9 R2 d1 @0 F: l' ^2 Q7 Y
9 d7 s, @$ x, V8 F- u
Syntax
! b0 Q: d0 U& u7 I; u
3 F# A% n- J/ h??V7 f1 o: Cylim(limits)
% x, E- s! {% E8 G) L2 F$ }4 H, a. e# t; B. k! ~
yl = ylim0 @??`3 l* A' x( c
7 s1 {( p5 F6 C??~2 Z8 z; E0 e7 o
ylim auto+ ~, N3 _; g; m: M; y
; s??X. w5 r( o. y1 ~6 Z3 Q' @
ylim manual1 ]- I* Q7 ]4 p7 O! n9 K) Y5 i! q: i
/ c0 I??`9 ^. k( j) k! T; u9 Im = ylim('mode')- [0 U; S; U; Y
; q/ S8 h5 i) H) u1 U" P7 g6 d/ H
___ = ylim(target,___)
2 i) K3 @. l??x) e8 t3 Q9 H9 b2 Q4 P# f# C* h: ^3 d5 n! P1 G( E
' T; @0 [- s+ R. P
Description) i6 P- P) f- P$ r1 e
7 m' L- N+ @. H( ?
ylim(limits) 設置當前坐標軸或圖表的 y 軸限制。將限制指定為窗體的兩個元素向量 [ymin ymax], 其中 ymax 大于 ymin。
, f. G& I, L% @5 s* ?- s, V3 `??H: h2 }0 P+ m
例子:3 n0 d! O" {" J( F4 ~$ w
1 P% g3 n/ N1 r! ], t
Plot a line and set the y-axis limits to range from -2 to 2.% `* i??S+ V# W' @4 A! L, u$ f+ d
q* {" g, t( }7 yx = linspace(0,10);
y = sin(x);
plot(x,y)
ylim([-2 2])( V9 ^. j5 p# }7 r; [
% e1 e. O8 Q2 H! F# [( w3 J
zlim的簡單介紹-10.png (18.74 KB, 下載次數: 0)
2019-12-28 09:32 上傳
0 n??S: D7 u+ a( q6 O! @* t& { ! \5 U: V; Y+ l: c& s
4 j: }9 B0 d* R. P/ Kyl = ylim??將當前限制返回為兩個元素向量。
5 ^- L+ g: d9 k/ v, g) E. Q
1 U6 s6 D6 B2 g; x例子:
- x8 I2 b% |6 h, q+ }% F% A' {2 [4 _3 P4 x
創建隨機數據的散點圖。返回 y 軸限制的值。) u* }4 L7 j8 ^: u) l" @
4 @; U! C: ?/ N??o3 c* U
x = randn(50,1);
y = randn(50,1);
scatter(x,y)
' i& c. w/ ?/ H1 c& C??n1 W
( {2 h9 F# G$ A4 Z0 I# j
zlim的簡單介紹-9.png (21.8 KB, 下載次數: 0)
2019-12-28 09:32 上傳
J1 L# w2 i2 p8 w* l3 A# v% {1 t
, s) V" Y1 d( |: a" w$ z( K0 w0 ]# ^
3 T% o9 }??N7 ?, c! [& {) y
ylim auto 設置自動模式, 使軸能夠確定 y 軸限制。限制跨越繪制數據的范圍。如果更改限制, 然后希望將其設置回默認值, 請使用此選項。此命令將軸的 YLimMode 屬性設置為 "auto"。
+ W$ [$ y' c0 c3 `
/ {' f??m! ~! M! w( nylim manual 設置手動模式, 凍結當前值的限制。如果要在使用 thehold 命令將新數據添加到坐標軸時保留當前限制, 請使用此選項。此命令將軸的 YLimMode 屬性設置為 "手動"。
# K: [9 ?( z/ s1 `8 V! ^+ V& k0 s& @& d7 U- N$ \
例子:Maintain Current y-Axis Limits
E8 m7 ~??Q4 u& @3 G8 i??C4 ]* z; D, D, O; [1 N
First, plot a line.8 Y8 _- k; l: ~, ]0 {8 w
1 O, \7 R8 a, \5 v# w1 Lx = linspace(0,10);
y = sin(x);
plot(x,y)
+ P. d) a$ R# Y, S& E" Q' h??Q
$ c- q: y) n* X( s
zlim的簡單介紹-8.png (22.62 KB, 下載次數: 0)
2019-12-28 09:32 上傳
8 e( ^9 b& `5 i, f- j
{" R/ A+ G; @9 b. X" l& W??E: t: M7 v
Set the y-axis limits mode to manual so that the limits to not change. Use hold on to add a second plot to the axes.; y. _. E7 H% Q" z
$ x+ ]! G! c6 O% k4 n2 ~9 x
ylim manual
hold on
y2 = 2*sin(x);
plot(x,y2)
hold off
$ S, S2 s! S* V& @; Z2 @% v' s: l1 b# m: l5 r; j# R+ l
zlim的簡單介紹-7.png (26.37 KB, 下載次數: 0)
2019-12-28 09:32 上傳
/ U& ]2 f! y; T??x9 ]* C; y
/ D# a9 Q, W, l9 T' |5 i( ~! a8 I: K; G0 _% _5 T
The y-axis limits do not update to incorporate the new plot., ^8 h$ Q. b$ D* W+ W
. r) P" u: J: t, F3 J
Switch back to automatically updated limits by resetting the mode to automatic.
1 R0 [, E0 W' B6 c* T1 K8 z0 a
- C??L8 n7 X; I4 D& n+ o& wylim auto3 I8 l# S* E/ D
' V9 @; A. r! O1 s# l
zlim的簡單介紹-6.png (24.74 KB, 下載次數: 0)
2019-12-28 09:32 上傳
; F" F& D??k; [) k8 p0 k
# Z3 f* y2 R' W- o: Q
( V3 U??Q; |# Km = ylim ("mode") 返回當前的 y 軸限制模式, 即 "auto" 或 "manual"。默認情況下, 除非您指定限制或將模式設置為manual, 否則模式是auto。6 q: [# P% B7 C6 w3 i; q
6 r& o8 |/ `( Y
___ = ylim(target,___) 使用由目標指定的軸或圖表, 而不是當前坐標軸。將目標指定為以前任何語法的第一個輸入參數。如果原始語法支持輸出參數, 則可以包括輸出參數。在模式輸入周圍使用單引號, 例如, ylim (target , "auto")。
! d- M& X2 t& ~$ k+ M/ o0 `+ y" g
8 M- m4 E" j9 j1 y4 a' z, |$ x6 L例子:
9 H8 ]+ J??@' B+ h* \
; x" A8 A% l1 v0 o8 yCreate a figure with two subplots and assign the Axes objects to the variables ax1 and ax2. Plot the same data in each subplot. Set the y-axis limits for the bottom subplot by specifying ax2 as the first input to ylim.
t) F) W1 A, n' a) \, N9 d. e2 F9 O??i6 f. j
創建一副擁有兩個子圖的圖像,并把 Axes對象賦值給兩個變量 ax1和ax2。在兩幅子圖中畫同樣的數據。通過將 ax2 指定為 ylim 的第一個輸入, 為底部子圖設置 y 軸限制。& E/ r6 s7 W6 K
( _9 P, X) m. z+ G9 Jclc
clear
close all
x = linspace(0,10,1000);
y = sin(10*x).*exp(.5*x);
ax1 = subplot(2,1,1);
plot(x,y)
ax2 = subplot(2,1,2);
plot(x,y)
ylim(ax2,[-10 10])
: O. D: j" i5 @( T) a3 i, ]2 f' g
: |??E# o) s9 D+ g; c. D, C0 T
zlim的簡單介紹-5.png (27.7 KB, 下載次數: 0)
2019-12-28 09:32 上傳
4 T; I! R# ?- a: B% k
7 l. x: N6 h$ q; t+ B
/ j! T??M* y5 n再送幾個案例:$ s0 l8 e. g# a% s
* k+ Z/ n) _# jUse Semiautomatic y-Axis Limits- ~0 s+ ^! Q1 A. p- p
% B7 F/ `) T$ n5 F/ D0 yCreate a suRFace plot and show only y values greater than 0. Specify the minimum y-axis limit as 0 and let MATLAB choose the maximum limit.
3 O: T, m2 U) O! ^/ @% r6 \; [1 k$ e1 S+ F8 W
意思是畫一個surface圖,僅僅顯示y大于0的部分:3 X+ @* `' D2 q* ]
$ H; T3 z% B0 y0 w' O! O% l( E
[X,Y,Z] = peaks;
surf(X,Y,Z)
ylim([0 inf])6 @# v- @3 j; L8 {
2 S$ Y5 F7 d& A; x. d
zlim的簡單介紹-4.png (66.9 KB, 下載次數: 0)
2019-12-28 09:33 上傳
/ @7 O. g3 d5 u: T; v0 N
0 m??b- }3 C" k) ~
# k. f% S, L1 b5 N& {8 t. A
如果不加限制,也就是全都是auto模式:l??t: x2 E5 f
" b# n# S( M# G: q3 ?8 J
clc
clear
close all
[X,Y,Z] = peaks;
surf(X,Y,Z)3 u9 r! G' c4 U??- h. S' F: I# O1 P" J; L' k
zlim的簡單介紹-3.png (116.82 KB, 下載次數: 0)
2019-12-28 09:33 上傳
; ~% H3 }9 }4 P0 ~" q9 B9 e
% k( l??p. v! k5 E
* U) Z0 K9 M# i' ^% F只關注y軸就可以看出區別了。# i+ A' [: J: w$ h1 X" o6 ]
8 H- i: N3 L& z' |% n+ |6 s7 gSet Limits for y-Axis with Dates1 ^; m; K+ E6 C) h1 F/ O* f
3 ?- f- `( S5 \. |& G$ ^Create a horizontal bar chart with dates along the y-axis. Set the y-axis limits to range from June 1, 2014 to June 10, 2014.
, _6 ^3 t??b1 q1 A/ f' X$ A6 R- ~# C$ R8 Z. s8 |/ y2 e
意思是創建一個水平條形圖,日期位于y軸,設置y軸的限制為從 June 1, 2014 to June 10, 2014.. R# U) ?! W$ z. X1 b
0 V# R" o+ c! z, F& L( \t = datetime(2014,06,1) + caldays(0:20);
y = rand(21,1);
barh(t,y)
tstart = datetime(2014,06,1);
tend = datetime(2014,06,10);
ylim([tstart tend])( N( x, l+ i4 p! { ' `4 M; p- n??y3 K
zlim的簡單介紹-2.png (20.31 KB, 下載次數: 0)
2019-12-28 09:33 上傳
; k; [2 f$ s6 M! r: F, K* C0 k; G5 B
3 a2 K: G- K" b8 Y# {2 K! j如果不設限制:X% i" b7 F+ L+ @5 o
+ }0 @# |+ i5 Z
clc
clear
close all
t = datetime(2014,06,1) + caldays(0:20);
y = rand(21,1);
barh(t,y), ~$ K7 {( g/ z4 q- f6 z0 c * `) l8 Y6 a4 @??_
zlim的簡單介紹-1.png (21.09 KB, 下載次數: 0)
2019-12-28 09:33 上傳
' {- a4 g$ M. B9 I8 x. q* z5 r# R
. y+ g) t% m% G
3 ^* }7 S1 _9 H* f: F/ s# F! e% xxlim的用法和ylim幾乎一模一樣,這里僅僅給出英文版介紹,就不詳述了。zlim也一樣,就不說了。/ Z3 D8 c, e$ ?9 S
% w??~# N! }5 \6 zxlim0 u??D$ j??}. B' j4 _4 q
: h7 V6 f* r7 ?6 W- g, b) L( |. h
Set or query x-axis limits5 h/ U) C/ R& F- E5 N% _
2 W8 `1 z1 t$ d4 L5 R; o% q* E! Gcollapse all in page
. u! X( N, A( N??l7 z! @???
1 j# x! F& A5 ?4 m3 D3 GSyntax
0 s8 B0 ]( K9 z, Z4 \: y
5 ^' C/ c??y, u/ R8 p; C5 {0 Kxlim(limits)% I$ v2 u- {' V. N! z6 u+ P9 w" c) K
* |/ K( u; ~7 w! [4 ~
xl = xlim
4 ^9 H+ b9 q; z; {??N3 N0 Z! B
% q7 G8 [3 @6 M2 `' o1 sxlim auto
8 o6 F( M# r1 A6 p$ y; R
/ U??y# W6 R2 e7 ~6 Gxlim manual6 Z0 J* C2 H??M) `) J3 a6 h
! U" r+ t* B2 c% n" W: C) W8 B9 lm = xlim('mode')0 v5 J; r2 f( D5 d& X/ Z" n3 B
i; D. r/ l! \* k5 q6 Y" j
___ = xlim(target,___)% B* c" _. w" q
3 n0 p# a$ C9 o# [Description
& `9 B, N3 A$ ~/ J' R5 s6 N% [& b4 y0 p
example
2 H8 q! Z! e6 O' J??s* w; H5 `7 B, t/ R4 r! A
xlim(limits) sets the x-axis limits for the current axes or chart. Specify limits as a two-element vector of the form [xmin xmax], where xmax is greater than xmin.Z8 K$ Z- K% Y: E" E. M* z
# x$ I2 m* D5 X- }) s" I5 @$ lexample
& y; d0 A& u: u6 d8 J2 T
x- x) D. R/ Yxl = xlim returns the current limits as a two-element vector.
7 b2 _1 F( J- H6 Q1 x
! p8 c. ]4 @0 {9 V: Zxlim auto sets an automatic mode, enabling the axes to determine the x-axis limits. The limits span the range of the plotted data. Use this option if you change the limits and then want to set them back to the default values. This command sets the XLimMode property for the axes to 'auto'.
. s' C/ j8 s5 r; m8 b/ H) L2 j% `
8 D* ^/ j' A: o% O- t* @example7 d! E* E7 l% K8 o6 A! h
/ s; l2 O??D2 c% H
xlim manual sets a manual mode, freezing the limits at the current values. Use this option if you want to retain the current limits when adding new data to the axes using thehold on command. This command sets the XLimMode property for the axes to 'manual'.# H2 R' \8 m+ Q0 d* \' T6 c4 R& w
4 e! Z/ v% r3 n8 D5 C+ xm = xlim('mode') returns the current x-axis limits mode, which is either 'auto' or 'manual'. By default, the mode is automatic unless you specify limits or set the mode to manual.[2 D??O7 u$ n& I+ \
$ K. d6 l0 D% }
example
/ \5 k2 B/ w9 N3 A$ ]) C4 V% E' O+ B
___ = xlim(target,___) uses the axes or chart specified by target instead of the current axes. Specify target as the first input argument for any of the previous syntaxes. You can include an output argument if the original syntax supports an output argument. Use single quotes around the mode inputs, for example, xlim(target,'auto').
4 [+ P" d; q9 n, g2 N, ?( E# Z) v% o% H, k: ?/ w6 M
7 b8 [! A7 U0 S: H, p
* `1 I- [& I0 C6 [6 K5 H. Y$ M4 N3 t6 w! t
總結
以上是生活随笔為你收集整理的xlim用法matlab,MATLAB之xlim 、 ylim 、zlim的简单介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 腾势 D9 发布首次 OTA 更新:升级
- 下一篇: matlab人脸追踪,求大神帮助我这个菜