Code and Output

Code 6.1.1:

my_data = [

]

Output 6.1.1:

my_data =
[]

Code 6.2.1:

my_data = [
1 2 3 4
5 6 7 8
          ]

Output 6.2.1:

my_data =
1     2     3     4
5     6     7     8

Code 6.2.1:

favorite = input('What is your favorite number? ')

Output 6.2.1a:

What is your favorite number?

Output 6.2.1b:

What is your favorite number? 3
favorite =
     3

Code 6.2.2:

favorite = input('What is your favorite number between 2 and 7? ')

Output 6.2.2:

??? Undefined function or variable 'p'.

Code 6.2.3:

favorite = -inf;
while (favorite < 2) | (favorite > 7)
    favorite = ...
    input('What is your favorite number between 2 and 7? ')
end
disp('OK, got it!')

Output 6.2.3:

What is your favorite number between 2 and 7? 88
favorite =
    88
What is your favorite number between 2 and 7? 0
favorite =
     0
What is your favorite number between 2 and 7? 3
favorite =
     3
OK, got it!

Code 6.2.4:

favorite = 0;
while (favorite < 2) | (favorite > 7)
    favorite = ...
        input('What is your favorite number between 2 and 7? ')
    if (favorite < 2) | (favorite > 7)
        disp('Sorry, not a valid number between 2 and 7.')
        disp('Try again, please.')
    end
end
disp('OK, got it!')

Output 6.2.4:

What is your favorite number between 2 and 7? 1
favorite =
     1
Sorry, not a valid number between 2 and 7.
Try again, please.
What is your favorite number between 2 and 7? 8
favorite =
     8
Sorry, not a valid number between 2 and 7.
Try again, please.
What is your favorite number between 2 and 7? 5
favorite =
     5
Got it!

Code 6.3.1:

disp('Hit  to go on.')
commandwindow
pause

Code 6.4.1:

commandwindow
tic
response = input('What is five plus the square root of 64? ')
Reaction_Time = toc

Output 6.4.1:

response =
13
Reaction_Time =
3.4589

Code 6.5.1:

t = [-.5:.5:1]';

format bank
bank_format_t = t

format compact
compact_t = t

format rat
rational_format_t = t

format short
short_format_t = t

format short g
short_g_format_t = t

format long
long_format_t = t

format long g
long_g_format_t = t

format loose
loose_t = t

format   % return format to standard default
standard_format_t = t

Output 6.5.1:

bank_format_t =

-0.50
    0
 0.50
 1.00

compact_t =
-0.50
    0
 0.50
 1.00
rational_format_t =
-1/2    
0      
1/2    
1      
short_format_t =
-0.5000
0
0.5000
1.0000
short_g_format_t =
-0.5
   0
 0.5
   1
long_format_t =
-0.500000000000000
          0
0.500000000000000
1.000000000000000
long_g_format_t =
             -0.5
                0
              0.5
                1

loose_t =
             -0.5
                0
              0.5
                1

standard_format_t =

-0.5000
0
0.5000
1.0000

Code 6.6.1:

name = input('What is your name? ', 's')

Output 6.6.1:

What is your name? David
name =
David

Code 6.6.2:

name = input('What is your name? ', 's');
greeting = sprintf('Hello, %s, I will try to help you.', name);
greeting

Output 6.6.2:

What is your name? David
greeting =
Hello, David, I will try to help you.

Code 6.6.3:

piVal = sprintf('The approximate value of %s is %f', 'pi', pi)

Output 6.6.3:

piVal =
The approximate value of pi is 3.141593

Code 6.6.4:

first = 3.00;
second = 5.25;
int_vs_float = sprintf(['Here are two numbers, an integer,'...
   ' %d, and a float, %f.'], first, second)

Output 6.6.4:

int_vs_float =
Here are two numbers, an integer, 3, and a float, 5.250000.

Code 6.6.5:

twoLines = sprintf('two\nlines')

Output 6.6.5:

twoLines =
two
lines

Code 6.6.6:

effort = sprintf('Let''s give %d%% effort to the project!!!', 100)

Output 6.6.6:

effort =
Let's give 100% effort to the project!!!

Code 6.6.7:

disp(effort)

Output 6.6.7:

Let's give 100% effort to the project!!!

Code 6.6.8:

aNumber1234 = 1234
aString1234 = '1234'

Output 6.6.8:

aNumber1234 =
1234
aString1234 =
1234

Code 6.7.1:

fprintf('%s\n','Matlab can be fun.');

Output 6.7.1:

Matlab can be fun.

Code 6.7.2:

fprintf('%d',[1:10])
fprintf('\n\n')
fprintf('%e',[1:10])
fprintf('\n\n')
fprintf('%f',[1:10])
fprintf('\n\n')

Output 6.7.2:

12345678910

1.000000e+002.000000e+003.000000e+004.000000e+005.000000e+006.000000e+007.000000e+008.000000e+009.000000e+001.000000e+01

1.0000002.0000003.0000004.0000005.0000006.0000007.0000008.0000009.00000010.000000

Code 6.7.3:

fprintf('%6.2f',[1:10])
fprintf('\n')

Output 6.7.3:

1.00  2.00  3.00  4.00  5.00  6.00  7.00  8.00  9.00 10.00

Code 6.7.4:

Pi_matrix = linspace(pi,2*pi,10);
fprintf('%6.0f', Pi_matrix);
fprintf('\n');
fprintf('%6.2f', Pi_matrix);
fprintf('\n');

Output 6.7.4:

    3     3     4     4     5     5     5     6     6     6
3.14  3.49  3.84  4.19  4.54  4.89  5.24  5.59  5.93  6.28

Code 6.7.5:

format long
Pi_matrix(1:4)

Output 6.7.5:

ans =
3.141592653589793   3.490658503988659   3.839724354387525   4.188790204786391

Code 6.7.6:

fprintf('%4d',[1:10]);
fprintf('\n\n');
fprintf('%5d',[1:10]);
fprintf('\n\n');
fprintf('%6d',[1:10]);

Output 6.7.6:


   1   2   3   4   5   6   7   8   9  10

    1    2    3    4    5    6    7    8    9   10

     1     2     3     4     5     6     7     8     9    10

Code 6.7.7:

fprintf('%d\t',[1:10].^4);

Output 6.7.7:

1     16   81   256  625  1296 2401 4096 6561 10000

Code 6.7.8:

a = [3.1:5.1];
b = [3:5];
c = a*2;
d = b + 2;
fprintf('%6.2f',a);
fprintf('%4d',b);
fprintf('\n');
fprintf('%6.2f',c);
fprintf('%4d',d);
fprintf('\n');

Output 6.7.8:

  3.10  4.10  5.10   3   4   5
6.20  8.20 10.20   5   6   7

Code 6.7.9:

a = [3.1:5.1];
b = [3:5];
c = a*2;
d = b + 2;
fprintf('%6.2f',a); fprintf('%4d',b); fprintf('\n');
fprintf('%6.2f',c); fprintf('%4d',d); fprintf('\n');

Output 6.7.9:

  3.10  4.10  5.10   3   4   5
6.20  8.20 10.20   5   6   7

Code 6.7.10:

a= [1 2 3 4 5];
asq = a.*a;
for i = 1:5
     fprintf('The square of %d is %2d\n',a(i),asq(i))
end

Output 6.7.10:

The square of 1 is  1
The square of 2 is  4
The square of 3 is  9
The square of 4 is 16
The square of 5 is 25

Code 6.8.1:

fid = fopen('mydata.txt','wt');
rr = [1.1:5.1];

fprintf(['Data echoed to Command window as it is written'...
     ' to mydata.txt\n'])
fprintf('%6.1f',rr);       % to Command window
fprintf(fid,'%6.1f',rr);   % to file associated with fid

fprintf(fid,'\n');     
fprintf('\n');

fprintf('%6.1f',rr+2);
fprintf(fid,'%6.1f',rr+2);
fprintf('\n\n')
fclose(fid);

fprintf('Data as read from mydata.txt:\n')
type mydata.txt

Output 6.8.1:

Data echoed to Command window as it is written to mydata.txt
1.1   2.1   3.1   4.1   5.1
3.1   4.1   5.1   6.1   7.1

Data as read from mydata.txt:

1.1   2.1   3.1   4.1   5.1
3.1   4.1   5.1   6.1   7.1

Code 6.8.2:

data = [78:90];
dlmwrite('my_dlm_data.txt',data,'\t');
type my_dlm_data.txt;

Output 6.8.2:

78    79  80   81   82   83   84   85   86   87   88   89   90

Code 6.9.1:

a= [1 2 3 4 5];
acube = a.^3;
myoutfile = fopen('CubesList.txt','wt');
for i = 1:5
     fprintf(myoutfile,'The cube of %d is %3d\n',a(i),acube(i));
end
fclose(myoutfile);
type('CubesList.txt');

Output 6.9.1:

The cube of 1 is   1
The cube of 2 is   8
The cube of 3 is  27
The cube of 4 is  64
The cube of 5 is 125

Code 6.10.1:

ls

Output 6.10.1:

CubesList.txt  my_dlm_data.txt   mydata.txt

Code 6.10.2:

dir *.m

Output 6.10.2:

my_dlm_data.txt  mydata.txt

Code 6.10.3:

pwd

Output 6.10.3:

ans =
C:\Lab and Teach\PSU Teaching\Programming Seminar\Textbook

Code 6.10.4:

cd('D:\MATLAB of David\')
pwd

Output 6.10.4:

ans =
D:\MATLAB of David

Code 6.10.5:

cd('..')     % [or:]   cd ../
pwd

Output 6.10.5:

ans =
D:\

Code 6.10.6:

cd('\Lab and Teach\PSU Teaching\Programming Seminar\Textbook')
pwd
cd('../Exercises')
pwd

Output 6.10.6:

ans =
C:\Lab and Teach\PSU Teaching\Programming Seminar\Textbook
C:\Lab and Teach\PSU Teaching\Programming Seminar\Exercises

Code 6.11.1:

data_from_file = load('mydata.txt')

Output 6.11.1:

data_from_file =
1.1000    2.1000    3.1000    4.1000    5.1000
3.1000    4.1000    5.1000    6.1000    7.1000

Code 6.11.2:

myinfile = fopen('cubeslist.txt');
nlines = 0;
while true
    thisline = fgetl(myinfile);
    nlines = nlines + 1;
    fprintf('Line %d:  %s\n',nlines,thisline);
    if feof(myinfile)
        disp('all done!')
        break
    end
end

Output 6.11.2:

Line 1:  The cube of 1 is   1
Line 2:  The cube of 2 is   8
Line 3:  The cube of 3 is  27
Line 4:  The cube of 4 is  64
Line 5:  The cube of 5 is 125
all done!

6.12.1:

M = xlsread('data.xls');

Output 6.12.2:

M = xlsread('data.xls', 'Experiment 2');

Code 6.12.3:

xlswrite('My_Excel_File', M);

Code 6.13.1:

filename = input('File name: ', 's');
if ~exist(filename)
    dlmwrite('my_dlm_data.txt',data,'\t');
else
    disp(['Error: the file ''' filename ''' already exists!']);
end

Output 6.13.1:

File name: my_dlm_data.txt
Error: the file 'my_dlm_data.txt' already exists!

Code 6.13.2:

timeofday = clock;
FirstOutputfilename = ...
    sprintf('Expt5_%02d_%02d_%02d_T%02d%02d%02d.txt',...
    round(timeofday(1:6)))
inits = input('Subject initials: ','s');
SecondOutputfilename = strcat('Expt5_',inits,'_',...
    sprintf('%02d_%02d_%02d',timeofday(1:3)),'.txt')

Output 6.13.2:

FirstOutputfilename =
Expt5_2013_08_25_T164855.txt
Subject initials: EF
SecondOutputfilename =
Expt5_EF_2013_08_25.txt

Code 6.14.1:

% Step1Program.m
rawdata = load('mydata.txt');
% Perform the analysis to convert raw to summary data here
save('DatafromStep1.mat', 'summarydata')
whos

Output 6.14.1:

  Name                       Size            Bytes  Class  

FirstOutputfilename        1x26               52  char   
Firstoutputfilename        1x26               52  char   
SecondOutputfilename       1x20               40  char   
a                          1x6                48  double 
summarydata                23x33            6072  double 
ans                        1x20               40  char   
b                          1x24               48  char   
d                          2x5                80  double 
filename                   1x15               30  char   
inits                      1x2                 4  char   
mydata                     2x5                80  double 
outputfilename             1x20               40  char   
rawdata                    2x5                80  double 
timeofday                  1x6                48  double 

Code 6.14.2:

% Step2Program.m
clear
load('DatafromStep1.mat')
whos
% Now perform the analysis on the summary data.

Output 6.14.2:

  Name                    Size            Bytes  Class   

summarydata             23x33            6072  double 

Code 6.15.1:

Help iofun

Output 6.15.1:

  File input/output.

File import/export functions.
  dlmread     - Read delimited text file.
  dlmwrite    - Write delimited text file.
  load        - Load workspace from MATLAB (.mat) file.
  save        - Save workspace or variables to MATLAB (.mat) file
  importdata  - Load workspace variables disk file.
  wk1read     - Read spreadsheet (.wk1) file.
  wk1write    - Write spreadsheet (.wk1) file.
  xlsread     - Read spreadsheet (.xls) file.

Problem 6.16.1

A
1.0    2.0    3.0    4.0    5.0    6.0    7.0    8.0    9.0   10.0
11.0   12.0   13.0   14.0   15.0   16.0   17.0   18.0   19.0   20.0
21.0   22.0   23.0   24.0   25.0   26.0   27.0   28.0   29.0   30.0
31.0   32.0   33.0   34.0   35.0   36.0   37.0   38.0   39.0   40.0
41.0   42.0   43.0   44.0   45.0   46.0   47.0   48.0   49.0   50.0
51.0   52.0   53.0   54.0   55.0   56.0   57.0   58.0   59.0   60.0

B
1.0    4.0    9.0   16.0   25.0   36.0   49.0   64.0   81.0  100.0
121.0  144.0  169.0  196.0  225.0  256.0  289.0  324.0  361.0  400.0
441.0  484.0  529.0  576.0  625.0  676.0  729.0  784.0  841.0  900.0
961.0 1024.0 1089.0 1156.0 1225.0 1296.0 1369.0 1444.0 1521.0 1600.0
1681.0 1764.0 1849.0 1936.0 2025.0 2116.0 2209.0 2304.0 2401.0 2500.0
2601.0 2704.0 2809.0 2916.0 3025.0 3136.0 3249.0 3364.0 3481.0 3600.0

Problem 6.16.4

number_of_employees = 100;
passwords = randi(899999,number_of_employees,1)+100000

yourpassword = input('What is your 6 digit password?  ', 's')
if passwords(employee_number,:) == str2num(yourpassword)
disp([OK_to_enter])
end

Problem 6.16.7

Marginal sums for N = 5

17 24  1  8 15 | 65
23  5  7 14 16 | 65
 4  6 13 20 22 | 65
10 12 19 21  3 | 65
11 18 25  2  9 | 65
-- -- -- -- --
65 65 65 65 65

Solutions

% Chapter 6 problems

% To generate the solution for one problem, copy and run the code for that
% problem in a file or in the Command window.

% To generate the solution for all problems in the chapter,
% run this program.

%
% Problem 6.16.1
%
% Write a program that yields the output shown below. Note that each
% element of B is the corresponding element in A, squared. Each value
% appears in the output with 7 columns per number and with 1 place to
% the right of the decimal point. The output should look like this:
%
% A
%     1.0    2.0    3.0    4.0    5.0    6.0    7.0    8.0    9.0   10.0
%    11.0   12.0   13.0   14.0   15.0   16.0   17.0   18.0   19.0   20.0
%    21.0   22.0   23.0   24.0   25.0   26.0   27.0   28.0   29.0   30.0
%    31.0   32.0   33.0   34.0   35.0   36.0   37.0   38.0   39.0   40.0
%    41.0   42.0   43.0   44.0   45.0   46.0   47.0   48.0   49.0   50.0
%    51.0   52.0   53.0   54.0   55.0   56.0   57.0   58.0   59.0   60.0
%
% B
%     1.0    4.0    9.0   16.0   25.0   36.0   49.0   64.0   81.0  100.0
%   121.0  144.0  169.0  196.0  225.0  256.0  289.0  324.0  361.0  400.0
%   441.0  484.0  529.0  576.0  625.0  676.0  729.0  784.0  841.0  900.0
%   961.0 1024.0 1089.0 1156.0 1225.0 1296.0 1369.0 1444.0 1521.0 1600.0
%  1681.0 1764.0 1849.0 1936.0 2025.0 2116.0 2209.0 2304.0 2401.0 2500.0
%  2601.0 2704.0 2809.0 2916.0 3025.0 3136.0 3249.0 3364.0 3481.0 3600.0
clc
commandwindow
fprintf('\n\n          %s\n\n','Output 6.16.1')
A = 1:60;
B = A .^2;
fprintf('\nA\n');
fprintf('%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f\n',A);
fprintf('\nB\n');
fprintf('%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f%7.1f\n',B);
% Now make the output of B "tab-delimited", so you could copy from the
% Command window and paste into an Excel or SPSS spreadsheet.
fprintf('\nA_tabdelimited\n')
fprintf('%6.1f\t%6.1f\t%6.1f\t%6.1f\t%6.1f\t%6.1f\t%6.1f\t%6.1f\t%6.1f\t%6.1f\n',A);
% Another solution, left to the student, would be to make A and B 6 x 10
% matrices. In that case, the techniques of Problem 6.16.7 could be used
% to print the matrices, a solution that would accommodate different
% numbers of columns in the matrix;
% A = 1:60;
% A = reshape(A,6,10);
% B = A.^2;
% ...


% Problem 6.16.2
%
% Write a program that creates an Excel file that will serve as the
% spreadsheet into which data from a behavioral science experiment can
% be saved. The Excel file should have the following columns
% in each of 200 rows:
% Column 1: subject_number (1 to 200)
% Column 2: subject_number_parity (odd, denoted 1; or even, denoted 0)
% Column 3: NaN, serving as a placeholder for the response to be given.
% Column 4: NaN, serving as a placeholder for the accuracy of the response
% Column 5: A random value drawn from a normal distribution with mean
% equal to 0 and standard deviation equal to 1 for odd-numbered subjects,
% or a random value drawn from a normal distribution with mean equal to 10
% and standard deviation equal to 5 for even-numbered subjects.
% % Read the Excel file back into MATLAB to observe the effects of having
% inserted NaN in columns 4 and 5.
fprintf('\n\n          %s\n\n','Output 6.16.2')
fprintf('Solution left to the student.\n\n');

% Problem 6.16.3
%
% Write a program in which a user is asked for a password. The program
% should check whether the password is contained in a list of 3 acceptable
% 6-letter passwords, each of which begins with a letter, defined as follows:
% correct_passwords = ['A1B2C3'; 'B2C3A1'; 'C3A1B2']
% Idiot-proof the program so the user is not rejected prematurely
% if s/he makes a typing error (e.g. too many or too few characters),
% but only let the user respond to the input a set number of times
% (e.g., 4).
fprintf('\n\n          %s\n\n','Output 6.16.3')
fails = 0;
done = false;
while ~done && fails < 4
    candidate = input('Type your password: ','s')
    if length(candidate) ~= 6
        fails = fails + 1;
        disp('Problem: password must have 6 characters')
    else
        switch candidate
            case 'A1B2C3'
                done = true;
                fails = 0; %Flag success by setting fails to FALSE!
            case 'B2C3A1'
                done = true;
                fails = 0; %Flag success!
            case 'C3A1B2'
                done = true;
                fails = 0; %Flag success!
            otherwise
                fails = fails+1
        end
    end
end
if ~fails
    disp('SUCCESS: Open Sesame')
else
    disp('FAILURE: Your account has been locked. Contact Customer Service')
end



% Problem 6.16.4
%
% Modify the program from Problem 6.16.4 so passwords consist of
% six-digit numbers from 100,000 to 999,999, and the matrix
% of passwords is retrieved from an external file. You will need
% to create the external file first. Set it up so there are 100
% passwords for 100 employees. Later, for an employee to enter the
% system, the password s/he supplies must be the password associated
% with his or her employee number, which is 1 through 100. Two pieces
% of information will help you solve this fairly difficult problem.
% One is that you can generate a 100 × 1 matrix of passwords from
% 100,000 to 999,999 as follows:
%
% number_of_employees = 100;
% passwords = randi(899999,number_of_employees,1)+100000
%
% Second, you will need to convert the password number entered by the
% user to a number from a string. You can achieve this conversion with a
% command that will be officially premiered in Chapter 7, str2num. The
% following code segments will also be useful in this program. Note that
% the if statement need not immediately follow the input statement in your
% program. If you omit the 's', the input will already be a number.
%
% yourpassword = input('What is your 6 digit password?  ', 's')
% if correct_passwords(employee_number,:) == str2num(yourpassword)
% disp([OK_to_enter])
% end
fprintf('\n\n          %s\n\n','Output 6.16.4')
number_of_employees = 100;
passwords = randi(899999,number_of_employees,1)+100000;
fprintf('\nEmp.  Password');
fprintf('\n  .   .\n  .   .\n  .   .\n')
for i = 90:100
    fprintf('%3d   %6d\n',i,passwords(i))
end
save('Passwordfile.mat','passwords')
%
clear
load Passwordfile
employee_number = 100;
yourpassword = input(...
    'Employee 100, What is your 6 digit password?  ', 's')
if passwords(employee_number,:) == str2num(yourpassword)
    disp('OK_to_enter')
else
    disp('Access denied')
end

% Problem 6.16.5
%
% One format of data files that can be imported into Excel or SPSS
% has the following characteristics: The first line of such a file is
% a header file, a series of valid SPSS variable names, tab delimited.
% Subsequent lines are numerical with the subject number in the first
% column followed by the scores for that subject in subsequent columns
% (i.e. also tab delimited). Generate output to the Command window that
% describes data for 6 subjects and two conditions (call the conditions
% 'left' and 'right'). The header line will then read,
% subno left right
%
% and the first data line (second line printed out) will be
%
% 1 0.32 0.54
%
% if 0.32 and 0.54 are the two scores for subject 1. Print such a data
% set in the Command window using fprintf and verify that you can copy
% and paste the data set into Excel. Then modify your code to write into
% a data file (handednessdata.txt) with the same contents, rather than
% the Command window. Verify that you can open the file with Excel and
% that all the numbers end up in the right places.
%
% You can generate your dataset by thedata = [rand(6,2)]. The resulting
% matrix will have six rows (one for each subject) and two columns (the
% left and right score for each participant).
fprintf('\n\n          %s\n\n','Output 6.16.5')
fprintf('Solution left to the student.\n\n');

% Problem 6.16.6
% Use the FPRINTF command to write a limerick or haiku, on the topic of
% MATLAB programming, appropriately formatted, to the file MYPOETRY.TXT.
% Verify the content by TYPE MYPOETRY.TXT.
fprintf('\n\n          %s\n\n','Output 6.16.6')
s1 = 'A new Matlab coder at Penn State';
s2 = 'wasn''t sure yet her skills were first-rate.';
s3 = 'So she hit RUN with terror,';
s4 = 'but got nary an error.';
s5 = 'So she yelled ''I did it!'' and felt great!';
fout = fopen('mypoetry.txt','w');
fprintf(fout,'%s\n%s\n\t%s\n\t%s\n%s\n',s1,s2,s3,s4,s5);
fclose(fout);
type mypoetry.txt

% Problem 6.16.7
%
% Make an array using magic(N), where N can be any value between 3 and 9.
% Print out the array, along with the row and column sums (the marginal
% sums) in a table formatted like the one below. Write the program in a
% sufficiently general fashion that it would work for any square array,
% not just the one you tested. Test your program on M = randi(9,N,N) as
% well as on magic(N);
%
% Marginal sums for N = 5
%
%  17 24  1  8 15 | 65
%  23  5  7 14 16 | 65
%   4  6 13 20 22 | 65
%  10 12 19 21  3 | 65
%  11 18 25  2  9 | 65
%  -- -- -- -- --
%  65 65 65 65 65
fprintf('\n\n          %s\n\n','Output 6.16.7')
fprintf('Solution left to the student.\n\n');

Output 6.16.1

A
1.0    2.0    3.0    4.0    5.0    6.0    7.0    8.0    9.0   10.0
11.0   12.0   13.0   14.0   15.0   16.0   17.0   18.0   19.0   20.0
21.0   22.0   23.0   24.0   25.0   26.0   27.0   28.0   29.0   30.0
31.0   32.0   33.0   34.0   35.0   36.0   37.0   38.0   39.0   40.0
41.0   42.0   43.0   44.0   45.0   46.0   47.0   48.0   49.0   50.0
51.0   52.0   53.0   54.0   55.0   56.0   57.0   58.0   59.0   60.0

B
1.0    4.0    9.0   16.0   25.0   36.0   49.0   64.0   81.0  100.0
121.0  144.0  169.0  196.0  225.0  256.0  289.0  324.0  361.0  400.0
441.0  484.0  529.0  576.0  625.0  676.0  729.0  784.0  841.0  900.0
961.0 1024.0 1089.0 1156.0 1225.0 1296.0 1369.0 1444.0 1521.0 1600.0
1681.0 1764.0 1849.0 1936.0 2025.0 2116.0 2209.0 2304.0 2401.0 2500.0
2601.0 2704.0 2809.0 2916.0 3025.0 3136.0 3249.0 3364.0 3481.0 3600.0

A_tabdelimited
1.0   2.0   3.0   4.0   5.0   6.0   7.0   8.0   9.0   10.0
11.0   12.0   13.0   14.0   15.0   16.0   17.0   18.0   19.0   20.0
21.0   22.0   23.0   24.0   25.0   26.0   27.0   28.0   29.0   30.0
31.0   32.0   33.0   34.0   35.0   36.0   37.0   38.0   39.0   40.0
41.0   42.0   43.0   44.0   45.0   46.0   47.0   48.0   49.0   50.0
51.0   52.0   53.0   54.0   55.0   56.0   57.0   58.0   59.0   60.0

Output 6.16.2

Solution left to the student.

Output 6.16.3

Type your password: A1B2C3
candidate =
A1B2C3
SUCCESS: Open Sesame

Output 6.16.4

Emp.  Password
.   .
.   .
.   .
90   835865
91   815348
92   679886
93   440749
94   830422
95   579543
96   415655
97   945101
98   888348
99   595141
100   660227
Employee 100, What is your 6 digit password?  660227
yourpassword =
660227
OK_to_enter

Output 6.16.5

Solution left to the student.

Output 6.16.6

A new Matlab coder at Penn State
wasn't sure yet her skills were first-rate.
 So she hit RUN with terror,
 but got nary an error.
So she yelled 'I did it!' and felt great!

Output 6.16.7

Solution left to the student.