An Environmental Database Matlab Help

An Environmental Database

Data collection is important for early detection of changes in our environment. In order to detect such changes, we need to be able to analyze the database efficiently, and this effort requires a database that is set up for easy access. As a simple example, suppose you want to create a 2 x 2 cell array A, whose cells contain the ‘location, the date, the air temperature (measured at 8 A.M., 12 noon, and 5 P.M.), and the water temperatures
measured at the same time in thee different points in a pond. The cell array looks like the following.

Capture

Solution

You can create this array by typing the following either in interactive mode or in a script file and ‘running it.

A(l,l) {‘Walden Pond’};
A(1.2) {‘June 13, 1997’};
A(2,1) {[60,72,65) };
A(2,2) {[55,57,56;54,56,55;52,55,53) };

If you do not yet have contents for a particular cell, you can type a pair of empty oraces { } to denote an empty cell, just as a pair of empty brackets [ ) denotes an empty numeric array. This notation creates the cell but doe~ not store any contents in it.

To use content indexing, enclose in braces the cell subscripts on the left side using the standard array notation. Then specify the cell contents on the right side of the assignment operator. For example:

A(l,l) {‘Walden Pond’};
A(1.2) {‘June 13, 1997’};
A(2,1) {[60,72,65) };
A(2,2) {[55,57,56;54,56,55;52,55,53) };

Type A at the command line. You will see

A =

‘Walden Pond’                      June 13, 1997′
[1×3 double]                            [1×3 double]

You can use the cell displays function to display the full contents. For example, typing
cell displays (A) displays
A{l, I} =
Walden Pond
A{2,1}
60 72 65
etc.

Posted on July 30, 2015 in Numeric Cell And Structure Arrays

Share the Story

Back to Top
Share This