next up previous contents
Next: Type Cast Functions Up: Inspection Functions Previous: ISEMPTY Test For Variable   Contents

Subsections

ISA Test Type of Variable

Usage

Tests the type of a variable. The syntax for its use is

   y = isa(x,type)

where x is the variable to test, and type is the type. Supported built-in types are

Examples

Here are some examples of the isa call.

--> a = {1}
a = 
  <cell array> - size: [1 1]
 [1]  
--> isa(a,'string')
ans = 
  <logical>  - size: [1 1]
 0  
--> isa(a,'cell')
ans = 
  <logical>  - size: [1 1]
 1

Here we use isa along with shortcut boolean evaluation to safely determine if a variable contains the string 'hello'

--> a = 'hello'
a = 
  <string>  - size: [1 5]
 hello
--> isa(a,'string') & strcmp(a,'hello')
ans = 
  <logical>  - size: [1 1]
 1

next up previous contents
Next: Type Cast Functions Up: Inspection Functions Previous: ISEMPTY Test For Variable   Contents
Samit K. Basu 2005-03-16