![$\textstyle \parbox{3in}{
\begin{equation}
{\bf M} \equiv \left[
\begin{array}{c...
...s & \vdots & S_3-1 \\
\vdots & \vdots & S_3
\end{array}\right]
\end{equation}}$](img4.png)
![]() |
(1) |
Begin by creating a directory ``
/A1'' in which you shall put all of the
work for this first assignment. Working in ``
/A1'', create a file
``setup.m'' containing a single line of octave code:
S=[3; 4; 5]Verify that you can run octave by starting octave (in the same directory ``
S = 3 4 5
Next, create the first two columns of M by adding the following lines to ``setup.m'' immediately after the statement declaring S
%# Code fragment to create columns of m1, m2, m3 indices and the matrix M ms=[0:prod(S)-1]'; %# Count from zero to S1*S2*s3-1 in a column vector m1=rem(ms,S(1)); m2=rem(floor(ms/S(1)),S(2)); m3=rem(floor(ms/(S(1)*S(2))),S(3));Rerun ``setup.m'' and inspect and verify the result by entering first just ``m1'', then just ``m2'', and finally just ``m3'' at the octave command prompt. Note that you can inspect any part of the above expressions, such as ``floor(ms/S(1))'', by entering it at the command prompt. Also, by entering ``whos'', you can get a report of all of the variables currently defined and, very usefully, their dimensions. (The function size() may be used to find the size of any single object.) Finally, combine each of your columns into a matrix using the octave block matrix formation
M=[m1, m2, m3];Inspect and verify your final result by rerunning ``setup.m'' and entering ``M'' at the command prompt.
Finally, write a block of code to compute N, verifying your
results in a similar way.
Hint: Compute the columns of N from the corresponding
columns of M using forms such as
n1=m1-(m1>S(1)/2)*S(1);and then combine your result into the the final matrix.
Tomas Arias 2007-04-05