0 g& }8 F" x- p& r( M$ R函数 目的/作用 & D2 N6 R/ o2 a: Z7 \- A6 D5 uchar Convert to character array (string) 3 ?( y) Y J+ {8 R/ L) _: }' G+ M( |int2str Convert integer data to string 2 s W$ r) A1 b1 b# Pmat2str Convert matrix to string : S4 `2 z7 V, h% {num2str Convert number to string/ B' l+ S4 l! u7 a. e
str2double Convert string to double-precision value & _, k4 e1 x, sstr2num Convert string to number / ]& t2 F4 A/ F; h& h5 {native2unicode Convert numeric bytes to Unicode characters, B, d# B3 E0 D2 ]% ~; }9 x1 m
unicode2native Convert Unicode characters to numeric bytes 1 A+ _3 j8 T! ?+ g: r. g+ ?! }base2dec Convert base N number string to decimal number 7 H% T8 i- u& K5 W. |bin2dec Convert binary number string to decimal number 1 \6 }! [$ k1 t! Ydec2base Convert decimal to base N number in string 5 _" `9 u" _3 W) H ^, b e# X8 Adec2bin Convert decimal to binary number in string * B# y, F) D' f8 q# i$ hdec2hex Convert decimal to hexadecimal number in string 1 x. i6 U$ W4 r) J0 b/ l1 c& Qhex2dec Convert hexadecimal number string to decimal number ! o) A4 \" t( O, zhex2num Convert hexadecimal number string to double-precision number; G& [- r. O' t; u. f9 H& n
num2hex Convert singles and doubles to IEEE hexadecimal strings 4 a3 x4 t, N1 ^' _2 Ncell2mat Convert cell array to numeric array/ E: |/ T$ o8 p. z6 T8 l9 e$ a+ U
cell2struct Convert cell array to structure array& K7 [ m9 C0 {! ^3 Y3 _- x
cellstr Create cell array of strings from character array& Q6 x# v8 m, r. d. Z; f0 }% s( Y
mat2cell Convert array to cell array with potentially different sized cells $ o8 l0 \ A& Enum2cell Convert array to cell array with consistently sized cells# J( W3 {' ~/ ?
struct2cell Convert structure to cell array8 N. m) M% U8 j+ W4 |8 w. m7 ]
测定的数据类型 ; F$ S6 L# |- { Y' q f% s3 C. k6 q+ H5 k2 ]0 b
MATLAB 提供各种函数标识数据类型的变量。0 j; M' u7 l! q9 C* f+ L
3 k5 Q5 y* S, X/ }4 a- [下表提供了确定一个变量的数据类型的函数: ( D/ J7 i- n7 i" b! @# i0 u / I+ r7 s; Z, U4 L" W3 s# H" f) H函数 目的/作用4 L# I0 F; M$ Z+ y$ r2 R6 N$ j
is Detect state9 u1 {, Q" C* l
isa Determine if input is object of specified class+ j% [, V1 U$ l5 O
iscell Determine whether input is cell array ' P# A7 y+ i9 H8 s( s& iiscellstr Determine whether input is cell array of strings. o# e; ?% ?3 z$ `- d
ischar Determine whether item is character array& o1 j+ t" A' i
isfield Determine whether input is structure array field% Z' D9 ^2 B+ S, K0 X- Y+ S
isfloat Determine if input is floating-yiibai array* u: w* v/ V& Q k
ishghandle True for Handle Graphics object handles) Y5 k/ r4 N1 q7 k
isinteger Determine if input is integer array $ x7 V+ ^: Z* Xisjava Determine if input is Java object4 w8 ?8 A* t$ ^4 @+ g
islogical Determine if input is logical array- L2 Q3 C" ] e! m+ w/ }
isnumeric Determine if input is numeric array! r8 K# t2 C+ ?1 M# y5 m( v
isobject Determine if input is MATLAB object S( b6 }) Q8 u7 V) p+ Q
isreal Check if input is real array+ Y c9 T c2 p* b' K' t
isscalar Determine whether input is scalar7 t0 w+ e# m) h2 g* g% l b
isstr Determine whether input is character array - v+ H4 P0 C; R; {, M* Wisstruct Determine whether input is structure array0 _ r O$ ^# a6 f4 O% J$ |
isvector Determine whether input is vector $ @# d+ g3 _7 o" v* d! K( uclass Determine class of object# i( N) B* `0 e0 U+ p
validateattributes Check validity of array 1 v6 h; k9 a# ]) _, M& Q0 Pwhos List variables in workspace, with sizes and types $ |9 C( i2 ^7 X! H例子 1 J7 M4 [1 z y$ A% m3 p' O8 u7 e2 _; a! d
创建一个脚本文件,用下面的代码: 4 t( l' x$ x6 F2 o S0 \* o& x # L* R0 O; g3 ~: Mx = 30 c* `8 P" f1 p3 k, t6 m1 g. p
isinteger(x) 7 B$ O* A; W |! a7 Jisfloat(x)! |' o/ T" [3 A4 F
isvector(x)+ D6 x( ]2 j. `, X M
isscalar(x) * l, Z0 a; d4 H# N( o0 X. Kisnumeric(x), J2 P: {: J2 j: C
8 q+ N/ M# n& p4 E( }
x = 23.54 7 w: N7 D: B9 @5 u. d9 @7 {isinteger(x); L' l& n! P, g# A
isfloat(x)1 z2 ?9 L! i* z3 t; U
isvector(x) * p C, S6 [0 Oisscalar(x), ?, d0 N9 B( ~ g3 G8 r$ L
isnumeric(x) / l5 f d& e4 i0 c7 Z) H3 C4 T" c" _1 |- z9 f) Z$ e
x = [1 2 3] : q3 y# b& ]# ?0 D4 ~# Risinteger(x)2 s8 G3 ^: G) `% B2 r5 f x
isfloat(x)$ T/ ^. h& M' g' p5 @) F$ r
isvector(x) & ^$ m6 k6 N8 O; O* _isscalar(x) ! r3 X( g( K& v2 Y& j- B$ G8 A% _3 x0 Y' S
x = 'Hello' k, \) U6 e& F1 D; y1 E, `- N
isinteger(x) 6 O- `0 u% r( S7 Yisfloat(x)3 S$ m, G' ]8 Z1 D
isvector(x) ; [% ^1 I" V0 l. y4 B3 Visscalar(x)9 _2 e0 L' B+ N5 }' V6 v' K" h. C
isnumeric(x) f9 [' Y* R" s
当运行该文件,它会产生以下结果: * ~1 R9 \ g. X1 P6 b9 K7 h4 d! m" V( r/ C5 d+ H: M Z, J6 r) k& J
x = " _4 C' |% |, R# R1 W 3 : i! J8 y; X! X1 Q8 [( i+ r" O+ mans =1 J! R- i$ t* V) j
0! B: j$ t1 o0 ^6 e
ans =% v+ c- J6 j2 ~: T+ b
13 |) T9 P$ U- ^) i7 ]9 `
ans = " s* D! m" P% a* {0 q 1/ T7 ]1 U; M; d2 ]3 _
ans =! }. K" F& J* t; n) @
1! [9 D. A5 T& v
ans = + o. `; k. |& e+ y6 x 1$ E V, ?, L4 k H! H
x = - E: ^5 ^, h% Z& T9 H7 f 23.5400' r/ p9 x$ L G& h& |7 Q
ans =& D1 R" n. L. j
0 3 S' ^8 ^, s `) t& R; hans =! ]6 w- L* ~, M: A+ }$ n7 i2 S
1 : L& h( q7 P3 f9 Wans = : F* I& _$ d: D8 f" V 1 + m/ I! |' D- U7 t6 t8 g% Tans = Z8 _0 X' d4 m+ ` 1+ I6 T, T, N; X7 A8 ^' @
ans = , I6 r( ^9 \& E4 r A1 c 12 u. o% _" F2 F
x =" C4 o( K) V" V
1 2 33 [+ E' ^; e) w1 N# a m
ans =% a5 W3 K% m$ r8 q' Z
0 {1 O7 r) v- Z' B! g$ D0 O% |) Q9 wans = + V0 a: H5 L: O: n$ e% T" B 1! c$ t6 [0 r, Z' @% T
ans =7 I( Z9 C5 b. |# G4 c0 j! R+ S5 g
1 8 ?! C; G$ p' [ans =2 G5 |, p2 x. B L- }
0 1 q R$ s/ H/ q; T: {/ Mx = 8 n+ T% l: ?! _/ LHello5 U8 B& p: P$ S$ @2 d) ?5 G3 K
ans =9 F7 ]+ g- `$ V( S) y
0 % n0 F: P d& }9 C- Z' P: Fans = 3 j' z) q; W, B% h& s$ O$ |7 V+ ^ 0 / l5 J1 R* c8 U" F: Pans =0 J3 N/ p1 G0 x' [9 o+ n
1 }* z4 y& z8 d
ans =1 V8 l* ~6 c# e$ Q1 ^. Z
08 @. W) K% l0 M1 x7 w# c
ans = $ |$ w- d9 u+ [ 0/ X( I- f" |6 [' V5 x
\7 O5 t% I+ S5 l. P1 K( w* {' ]1 l————————————————( x& ?: A% S, B4 s
版权声明:本文为CSDN博主「Phil__ming」的原创文章。 7 J Q# h4 H1 T/ w. ~原文链接:https://blog.csdn.net/Poseidon__ming/article/details/750925755 {6 s v) G. E" Z1 \
: B& K. U7 p: E$ [