%
% hw1.m
%
%
% solutions to HW 1 for Matlab Bootcamp class
%
% k.drushka
% sept 2013
%
% 1. Create v1, a 4x1 column vector that contains any values you like.
v1=[2 4.4 99 -100];
% 2. Create v2, a 1x6 vector containing the values from 20 to 25.
v2=20:25;
% 3. Create v3, a 1x6 vector whose values are equal to 5 times the values in v2.
v3=v2*5;
% 4. Create a new figure. Make sure it is cleared of any previous plots. Plot v3 against v2 as a red dotted line with square markers. (Type help plot or do an internet search for ?Matlab line specification? to get some hints on plotting lines with different properties).
figure(1); % use figure 1
clf % clear the figure
plot(v2,v3,'r:s') % 'r' plots in red ':' makes a dotted line 's' makes a square marker
% 5. Create v4, a vector that goes from -2? to +2? containing at least 100 datapoints (i.e. the length of v4 should be at least 100).
v4=-2*pi:0.01:2*pi;
length(v4) % check the length of v4 to make sure it's at least 100 (the output will print to the screen)
% 6. Create v5, a vector equal to the cosine of v4 plus some nonzero offset (mean).
v5=cos(v4)+1.1;
% 7. Without erasing the figure, now v5 against v4.
hold on
plot(v4,v5)
hold off
% 8. Save your figure as a pdf.
print('-dpdf','hw1_plot');