![]() |
Exploiting MATLAB's Data Structures |
One of the most important uses of the cell array is to hold a bunch of strings of different lengths. In this problem you will learn how to work with cell arrays of strings.
Goal: Determine the list of variables that will conflict when you load in a MAT-file. Use who and who -file to create a list of the variables in each workspace. Use intersect or strmatch to determine if there will be any name clashes.
Key concepts: working with cell arrays of strings, creating cell arrays of strings, operating on cell arrays of strings.
Key functions: who, whos, load, intersect, strmatch
topo.mat contains matrices that can be
used to display a topographic map. Use who -file (or
whos -file) to determine the variables in the file
before loading them.
clear) and load the mat
file.
world.mat also contains matrices that
can be used to display a map. We'd like to load this file as well but we
need to make sure that the variables in the file don't conflict with what
we have in the workspace already. Use who and who
-file with an output argument to get the list of variables in
the workspace and file into cell arrays of strings (remember to use the
functional form: s = who('-file',filename)).
intersect or the function strmatch
to determine if any of the variables in world.mat will
conflict with the variables in the workspace. If so, what are the names
of the clashing variables?
![]()
Copyright © 1997 The MathWorks, Inc.
clay@mathworks.com
$Revision$ $Date$