68 advanced topic: the switch statement
Listing A.2: computer_test.m - Script to test type of computer MATLAB is running
on
1 % computer_test.m
2 % Script to test type of computer MATLAB is running on
3 %
4 % Craig Warren, 08/07/2010
6 % Variable dictionary
7 % myComputer Variable to hold information about computer
9 clear all; % Clear all variables from workspace
10 clc; % Clear command window
12 myComputer = computer; % Assign result of built−in computer
13 % function to myComputer variable
14 switch myComputer
15 case 'PCWIN'
16 disp('This computer is running Microsoft Windows, 32−bit');
17 case 'PCWIN64'
18 disp('This computer is running Microsoft Windows, 64−bit');
19 case 'GLNX86'
20 disp('This computer is running Linux, 32−bit');
21 case 'GLNXA64'
22 disp('This computer is running Linux, 64−bit');
23 case 'MACI'
24 disp('This computer is running Mac OS X, Intel, 32−bit');
25 case 'MACI64'
26 disp('This computer is running Mac OS X, Intel, 64−bit');
27 case 'SOL64'
28 disp('This computer is running Sun Solaris, 64−bit');
29 end