Your goal is to modify a (0,1)-matrix M (called a binary matrix) with two opera-
tions, reshape and (vertically or horizontally) stacking the two copies of the matrix
M so that the length of the longest zero sequence (an unbroken row of zeros hor-
izontally, vertically, or diagonally) in the matrix is maximized. However, there is
cost required to perform each operation as follows:
1. reshape(M, x, y): 3
2. stacking [M; M] or [M M]: 2
So, if you are given a budget of k, you can only use a nite number of these operations
such that the total sum of costs to perform operations is less than or equal to k.
For example, when k = 10, you cannot perform reshape more than 4 times.
You will write a code (i.e., MATLAB function) to modify the input (0,1)-matrix M
with a given budget k. The skeleton code can be downloaded from iCampus (http:
//www.icampus.ac.kr/). Please do not change the function name and arguments.
But, you can use some additional functions if you need them.
The constructed function longZeroSeq with the budget k and the matrix M as
input arguments executes MATLAB commands and then returns the length of the
longest zero sequence in the modied matrix.
You will be judged by (1) the correctness of the result returned by your MATLAB
function, and (2) the length of the longest zero sequence. For test, we will use
1 k 40 and 1 jMj 400 where jMj is the number of entries in the matrix
M. There is an 1 minute time limit for each run (we will measure the time to run
your code with `tic' and `toc').

 

매트랩 과제인데 좀 막막해서 올려봐여..

 

skeletoncode 는

function l = longZeroSeq(k,M)
    % l = longZeroSeq(k,M) computes the
    % length of the matrix derived from the matrix M,
    % with reshape and stacking operations within k budget.
    % reshapre and stacking operations require 3 and 2 costs, respectively.
end  임