%Psych 583B
%Homework 1
%Geoff Boynton

%1) Create the following vectors using both linspace and the ':' technique:
%a) [1 2 3 4 5 6 7 8 9 10]
%Colon method:
1:10
%Linspace method
linspace(1,10,10)

%b) [10 8 6 4 2 0 -2 -4]
%Colon method:
10:-2:-4
%Linspace method:
linspace(10,-4,8)

% c) [0 3.1416 6.2832 9.4248 12.5664 15.7080]
%Colon method:
0:pi:16  %Could have used: pi:pi:pi*5
%Linspace method
linspace(0,pi*5,6)

%2) Start with the following string: 

str = 'aaaaaaaaaaaaaaaaaaaa';

%a) Make every third letter in the string 'c'

str(3:3:end) = 'c';
disp(str);

%b) Then use indexing to turn the string into: 'abcabcabcabcabcabcab'

str(2:3:end) = 'b';
disp(str);

%c) Now use indexing to turn the string into: 'abcdefabcabcabcabcab'

str(4:6) = 'def';
disp(str)

%d) Finally, use indexing to turn the string into: 'abcdefabcdefabcdefab'

str(10:12) = 'def';
str(16:18) = 'def';
disp(str);

%e) Demonstrate that the 6th, 12th and 18th letters in the string are f's

disp(str([6,12,18]))