hw12_reshape - % ---- Calculation & Output...

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

View Full Document Right Arrow Icon
function[new_vector]=hwk12_reshape(A,r,c) %This function reshapes a vector. % INPUT ARGUMENTS: A - image array % r - new number of rows % c - new number of columns % OUTPUT ARGUMENTS: new_vector - converted vector with r rows and c columns % % ---- Input Section ---- s = 1; t = 1; vect_size = size(A); new_vector = zeros(r,c);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % ---- Calculation & Output Section ----if r*c ~= vect_size(1)*vect_size(2) disp('You must have the same number of terms in the reshaped vector as in the original vector.') else for y=1:c for x=1:r new_vector(x,y) = A(s,t); if s < vect_size(1) s = s + 1; else s = 1; t = t + 1; end end end end...
View Full Document

This note was uploaded on 02/12/2012 for the course ENGR 126 taught by Professor Oakes during the Fall '08 term at Purdue University-West Lafayette.

Ask a homework question - tutors are online