, Z7 T% l& P& V* f函数 目的/作用/ [2 n% f0 k* { j% e. O
char Convert to character array (string); ^- b7 [2 }2 e- n5 U2 Y3 i4 p
int2str Convert integer data to string 7 `" t# n7 S' i% S3 e6 u, pmat2str Convert matrix to string 3 x; F1 Y% x; l; E4 H5 ?num2str Convert number to string 6 h- B. `) V" astr2double Convert string to double-precision value1 W% J* j/ f d2 K
str2num Convert string to number % ?, k+ A* G+ X0 Onative2unicode Convert numeric bytes to Unicode characters/ \9 v6 }! V+ M: r! @
unicode2native Convert Unicode characters to numeric bytes- V! N3 s$ t3 B( I) u" {3 N
base2dec Convert base N number string to decimal number! m; v- R, z1 x* _9 O
bin2dec Convert binary number string to decimal number , o3 i! q# S) w7 r4 ]& Y( d6 udec2base Convert decimal to base N number in string $ H7 b- E3 G: O2 q7 Z5 D7 Fdec2bin Convert decimal to binary number in string 7 Z$ }6 ~: u+ kdec2hex Convert decimal to hexadecimal number in string 3 a2 S$ B5 @2 Z+ e! q: z! M/ Whex2dec Convert hexadecimal number string to decimal number- S! }0 C0 B% q
hex2num Convert hexadecimal number string to double-precision number) R0 }8 u: H* A- F
num2hex Convert singles and doubles to IEEE hexadecimal strings & G" C! `6 `7 i% d0 l8 z) p% D& {cell2mat Convert cell array to numeric array4 h& [5 x( J. Z
cell2struct Convert cell array to structure array 2 \/ `( ^$ g8 G3 d$ _cellstr Create cell array of strings from character array, ?6 A& e2 @) N/ h7 Y
mat2cell Convert array to cell array with potentially different sized cells$ _. ^1 l' h4 e9 @0 q$ z/ N# `) ]
num2cell Convert array to cell array with consistently sized cells " V K9 i) v( v- hstruct2cell Convert structure to cell array. E. o, C0 _0 n2 Q: G
测定的数据类型 : D E g. b9 c W7 l 6 k/ P5 |' |" f `2 B; T+ _MATLAB 提供各种函数标识数据类型的变量。' f2 A" }+ l3 E& B
4 l7 n9 L" m7 O5 l, r下表提供了确定一个变量的数据类型的函数: , J9 V7 \3 ^$ P, K( t5 B0 U- ]- n* K% m- v
函数 目的/作用 / E0 @5 r7 u$ j- wis Detect state * j& S8 p* m G- K2 [/ J3 Lisa Determine if input is object of specified class 0 g: c& J2 Y5 l4 { |7 k9 uiscell Determine whether input is cell array ' t* S8 i+ L/ n5 W3 Niscellstr Determine whether input is cell array of strings8 y! u" Y3 d7 I7 D% G% Z/ H0 m
ischar Determine whether item is character array - T4 \7 u! O8 c9 d8 V: Aisfield Determine whether input is structure array field6 {) N8 N# c- R: _2 C
isfloat Determine if input is floating-yiibai array& r; ?/ P' A U( O8 @3 t) \
ishghandle True for Handle Graphics object handles; y1 `+ P8 O; A& P
isinteger Determine if input is integer array ( b) U' J% p- r& gisjava Determine if input is Java object2 z% F1 `5 e- R
islogical Determine if input is logical array6 \4 X6 N: j) s8 ]
isnumeric Determine if input is numeric array / s/ L* z- a; W; | J/ d+ H* Cisobject Determine if input is MATLAB object1 d. b* \% k4 I8 i! x7 G0 k
isreal Check if input is real array 4 V2 V- O# T$ i+ h0 n" Q. g5 X, aisscalar Determine whether input is scalar : s1 T, _6 s$ E+ K! Oisstr Determine whether input is character array # c5 _. O' o1 Y& ]: ~$ j7 misstruct Determine whether input is structure array+ `0 x$ H( @6 {! D( I
isvector Determine whether input is vector + F% i1 S7 Z+ o" p+ K8 }/ xclass Determine class of object 6 l7 n$ n' n8 p1 G8 }validateattributes Check validity of array" n1 I$ r6 f9 b: R3 B" I; u
whos List variables in workspace, with sizes and types2 _# R1 @+ v) E8 Z0 p) q3 D }
例子+ ~2 Q7 M; J( p4 p, R G
- }' ?2 k. O4 A) f- z创建一个脚本文件,用下面的代码: 5 K. |7 D! D0 Y" f2 u 8 A" p' T8 t# \: ?x = 3% H4 W0 ]0 F$ T* W& |/ v
isinteger(x) . x: m8 ^3 U7 D! B; U7 Z6 gisfloat(x) % A& e4 J( }5 i7 E9 ^$ R/ Bisvector(x) ! r# _: x2 h9 r0 b E9 l/ |* aisscalar(x)2 b$ ^- O/ f8 ^$ A3 u4 B4 B2 O0 T3 G
isnumeric(x) ) J# `. i( E9 Z, d5 r; m, y/ `7 |7 U
x = 23.54 3 M& Q7 j7 U9 V7 F; l2 [isinteger(x) ; \# @. E- Q8 G' w! C1 I' f: iisfloat(x)4 H4 y2 G) f) X; i
isvector(x)0 G$ R. C9 U8 k7 S& A4 T: r) k, d
isscalar(x)1 \) T- @& a E/ W
isnumeric(x)' E* n: R+ @* I T, ]2 S1 _
+ K, L# u- ~! J3 ]) w& Zx = [1 2 3]: s; h* n' O+ l* C, A) e
isinteger(x) ' z- W- L% D$ U, N! Lisfloat(x)" u8 Q% |: m1 S- C3 Y' `! }/ D
isvector(x) . h1 m6 S$ C6 r2 ^ }7 P. Qisscalar(x) 4 o; l7 o0 O ?, I5 W) Y3 g/ Q) M; l7 s9 r7 O) a/ Y
x = 'Hello'4 g2 C% e7 |' U1 Y% G3 g
isinteger(x) / p5 B9 ~9 d+ ~# e) S, S( Z) }isfloat(x)) M5 o8 s8 J0 D1 B
isvector(x) ) l3 ^, d% _0 Q0 a8 Q7 u& Disscalar(x)" i7 @8 r9 M5 a
isnumeric(x) ! p# G4 A8 _& \. T2 A, W$ B当运行该文件,它会产生以下结果: 5 \1 h9 q K9 N/ J9 O' \' R8 n0 B 9 _ M/ s2 D8 X: X. e( Wx = ) U1 G+ c2 D+ k; j5 C 3 # ^5 }4 H/ ~: [: k. tans = e# C4 y) ?7 q
0/ y! T# S1 \, ~' P) G1 ^) r
ans =8 G2 u2 v+ Y2 u/ v) r0 U
1: T- ?; f& D2 L9 \
ans = & q1 V# Q$ ~! ] 1- F5 ~/ [: @0 U; |4 I( @2 I
ans = 3 c+ |* [0 O- ^7 k 1( g) X$ V/ _( ~& a$ G" Q
ans = ?' s( e! y; a; f
1$ n( i, K. Y6 ]3 O
x = ^- i+ @& m9 u; B; z1 b& k
23.5400 6 u2 D% ~5 _6 R. t. Nans =4 ?$ S6 l# k3 H' Z8 R8 F" |' W
0& W4 J& S8 d+ h: i; N0 o1 y/ h
ans =5 E# `8 c0 t p- n
18 s( O/ [* \8 |& g! l" f; g
ans =3 W- I9 R' \; T
1: A4 e7 e: I3 _! T
ans = # Z0 r. Y) a# e: F0 a* j 1 6 Q6 `" \6 c. F& W* @ans = ! v9 x; e: z2 Q& G1 ]% v0 l+ f' Q 1 : K( V: N( X2 {- C+ m+ t D( Dx =% n" z0 s3 l1 V$ S& |7 e
1 2 3' |2 B! j5 j; O, Y* x6 \
ans =- Q. q% W* \; t7 ]( R# a
0 F ^8 ~2 ]+ f4 D5 tans =2 }( Q2 j; [+ g5 i- B
15 l9 B" ~( a1 [% O, o
ans = V4 B, ^0 ~1 Q: P% [& Q- e1 ] 1 % E: b) w) Y- v* L) S( V/ T* Eans =! ]: {9 L% H4 Q( E* _
0* g: B2 z- t4 A. R: {
x =5 E8 r1 |, e4 X# c
Hello/ p3 N" Y) f* h4 w, L- [0 e
ans =2 @" V0 D; u+ ~+ Q! x
0' H* R# O; E8 N) g7 b( [
ans = & K1 k+ Q' L$ R% } 0: B" N( E' ~! x# L( I9 X- i
ans = 0 w; M7 b% P9 Q6 Y# } 16 G7 b% G: @0 J( A' O/ Q
ans =0 n7 U5 x* |+ y
0 . F! F1 h6 ?) L2 ]' y- aans = # u1 s2 ^ M6 N+ y8 _1 O: J1 \ 0 ' p2 Y, S6 \- w5 @( Q1 n' z0 ^ G8 q# ?+ L: e4 ?8 h! l/ V
———————————————— J6 O8 @' a, }! k/ [' L
版权声明:本文为CSDN博主「Phil__ming」的原创文章。6 G$ \4 q! J+ j8 S: K
原文链接:https://blog.csdn.net/Poseidon__ming/article/details/75092575# p. m2 _& `; G: G3 D; V" n
2 v! D* T; N# B/ V6 y. k. ]3 h$ d$ b0 \0 u6 R& j7 [