When you're ready to begin, type "matlab" to start up Matlab. Then type "matmem" to start the matrix memory demo.
Experiment with the matmem demo:Questions: How many items can you store before the first retrieval error occurs? What percentage of memory bits are active when the first retrieval error occurs? Hit the New button and then Random to generate another set of data items. Try the experiment several times and report average values.
Questions: How many items can you store using the sparse representation? What percentage of memory bits are turned on when the first retrieval error occurs?
Complete this Matlab program to fill a memory with key-value pairs until the memory capacity is exceeded. The keys will be random. For the values to be stored, we'll use 1 for the first pattern, 2 for the second, and so on. Since the keys are not orthogonal, we will use the pseudo-inverse method to calculate the weight matrix. Here is the program; you need to fill in some missing parts.function Z = keyvec(N,B) % Generate an N-bit binary vector with a random B bits true Z=zeros(N,1); P = randperm(N); Z(P(1:B)) = 1;
Questions:N = 10; % length of a key B = 3; % number of 1 bits in a key Keys = []; Values = 0; % values to store Results = 0; % results of retrieval using Keys M = zeros(1,N); % weight matrix NumPatterns = 0; while max(abs(Values-Results)) < 1e-10 NumPatterns = NumPatterns + 1; k = keyvec(N,B) / B; % normalized random key Keys = [Keys k] Values = 1:NumPatterns; M = ... fill this in to construct the weight matrix Results = ... fill this in to retrieve the values given the keys end fprintf('Stored %d patterns without error.\n',NumPatterns-1);