MATLAB Guide

Chapter 18: Other Data Types and Multidimensional Arrays

Overview

So far in this book we have identified two of MATLAB's fundamental data types (or classes): double and sparse. There are several others, including char, cell, struct, storage and function handle. The storage data types are for memory-efficient storage and are of use only in specialized situations. In this chapter we describe the char, struct and cell data types. All the fundamental types are, in general, multidimensional arrays; we describe multidimensional arrays in the second section.

If you want to determine the data type of an object you can use the class function, which provides the same information as the last column of the output from whos. For example,

  <span class="unicode">?</span> class(pi)  ans =  double  <span class="unicode">?</span> class(speye(4))  ans =  sparse

You can also use the isa function to test whether a variable is of a particular class:

  <span class="unicode">?</span> isa(rand(2) ,'double')  ans =        1  <span class="unicode">?</span> isa (eye(2),' sparse')  ans =        0

18.1 Strings

A string, or character array (char array), is an array of characters represented internally in MATLAB by the corresponding ASCII values. Consider the following example:

  <span class="unicode">?</span> s = 'ABCabc'  s =  ABCabc<a name="441"></a><a name="page218"></a>  <span class="unicode">?</span> sd = double(s)  sd =       65  ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Biosensors and Microarrays
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.