Many of the homework assignment will require a MATLAB component. Please be sure they are done correctly.
;
at the end of the line. Error messages and long pages of extraneous output will
automatically earn you a "zero" on the problem.You will be expected to use the publish to html option in MATLAB to format your code and output. This feature creates a nicely formatted version of your work, which can be viewed in MATLAB or any web-browser. You should then print the html version of the work as displayed in MATLAB or the browser. Problems which are incorrectly formatted with receive zero credit Do not submit an assignment if you are unsure of the formatting. Email me or see me during office hours if you have any questions.
To format the published file correctly, you must use the correct MATLAB Markup. Lines starting
with %%
will refer to the main title and subsequent section title. Lines starting with %
placed after a line with %%
will be printed as the main text for the section, and will be used
to answer and state any observations about the problem. More details information about MATLAB's Publishing Markup
can be found here.
Example 1 The following code (in an m-file named sample.m):
%% Example problem
%% (a)
% Consider the function f(x) = sin(x)-x. Let x=10^-7 and print out y=f(x) with 15 digits.
%
% How many of these digits are correct???
x = 1e-7;
y = sin(x) - x;
fprintf('y = %.15g\n',y) % print y with 15 digits
%% (b)
% Plot the function f(x) for x in [0,10^-7].
%
% Why does the plot look like this???
x = linspace(0,1e-7,1000); % vector of 1000 equidistant points 0,...,1e-7
y = sin(x) - x; % vector of function values
plot(x,y) % plot vector y vs. vector x
xlabel('x')
title('function sin(x)-x')
will produce sample.html, which can then be printed.
Example 2 The following code:
%% Problem title
%% (a) Title of first part
% Description and comments
% and observations
% and so on
format compact % tells Matlab not to print blank lines between answers
v1 = [-1;2;2]
v2 = [2;-1;2]
innerproduct = dot(v1,v2) % gives zero, i.e. v1 and v2 are orthogonal
%% (b) Title of second part
% Description and comments
% and observations
% and so on
x = 0:.1:10; % use semicolon for stuff you don't want to print!
plot(x,sin(x),x,cos(x))
legend('sin(x)','cos(x)')
%% (c) Title of third part
% Note that Matlab is very picky about the format:
%
% * The % and %% must start in the first column
% * There should be exactly one space after %% and %
% * You can generate a bulleted list like this
will produce the following output.