Weave - array=zeros(rows,columns%creates an array of all zeros so that we do not have to index the zeros%we simply have to index where the 1s and

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function weaved=weave(rows,columns) %function to create a weave pattern on an array with m rows and n columns %according to the following criteria: % % 1. The even-indexed columns should be 1's. % 2. The even-indexed rows should be 2's. % 3. Starting at row 2, the first intersection between a 2 and a 1 % should be a 2. The next intersection should be a 1, then 2, and % so on. This will be repeated for every other row of 2's. % 4. Starting at row 4, the first intersection between a 2 and a 1 % should be a 1. The next intersection a 2, then 1, etc. Like the % previous part, this will be repeated for every other row of 2's. % 5. All other places in the array should be filled with zeroes.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: array=zeros(rows,columns); %creates an array of all zeros; so that we do not have to index the zeros, %we simply have to index where the 1s and 2s need to go array(:,2:2:end)=1; %at all of the rows and every even column, a 1 will be placed there; like %the picture array(2:2:end,:)=2; %at every even row and every column, a 2 will be placed there; like the %picture array(2:4:end,4:4:end)=1; %at every other even row and every fourth column, a 1 will be placed there array(4:4:end,2:4:end)=1; %at every fourth row and every other even column, a 1 will be placed there weaved=array; %sets the changed array equal to the weaved output...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online