12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

meteo.Temperatureans =24ans =19.0000 16.5000 15.3000We can capture this output in a cell array as follows:>> q = {meteo.Temperature}q =[24] [1x3double]Or, we can string them together in a single array by enclosing themeteo.Temperature expression in square brackets:>> q = [meteo.Temperature]q =24.0000 19.0000 16.5000 15.3000In this way you can operate on all elements <strong>of</strong> a field at once. Forexample, to calculate the mean <strong>of</strong> all the temperature measurements:>> mean([meteo.Temperature])ans =18.700028.2 Example: Capturing the List <strong>of</strong> VariablesTyping whos gives you a list <strong>of</strong> the variables present in the workspace,along with their size, the number <strong>of</strong> bytes they occupy, <strong>and</strong> their class.For example, create the following variables:cleara = 1;name = ’Jane Smythe’;vect = [1 2 3 ];acell = {1 2 ; ’big’ ’little’};meteo = struct(’Site’,{’Adelaide’,’Sydney’});The whos comm<strong>and</strong> produces the following list:>> whosName Size Bytes Classa 1x1 8 double arrayacell 2x2 402 cell arraymeteo 1x2 244 struct arrayname 1x11 22 char arrayvect 1x324 double arrayGr<strong>and</strong> total is 58 elements using 1396 bytesc○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!