From: Samuel on 27 Feb 2010 12:44 Given a 2D matrix A, I need to write a function that displays a subsection of the matrix subA given the following inputs: A – A 2-D matrix. [r,c] = size(A) where r>=i+m and c>=j+n i – An integer scalar. A row number in A were the requested subsection begins. j – An integer scalar. A column number in A were the requested subsection begins. m – the number of rows in the subsection n – the number of column in the subsection Anybody have any ideas on where I can find more information on this or how I can write this code? Thanks for all your help!
From: Oleg Komarov on 27 Feb 2010 12:48 "Samuel " <boo161620(a)yahoo.com> wrote in message <hmbl64$686$1(a)fred.mathworks.com>... > I am knew at writing matlab code, and I have this problem. Given a 2D matrix, A, of any size [r,c]=size(A), I need to be able to write a function that finds a sub-section of the matrix A from the given inputs, > 1. i=scalar, the row where the sub section begins, > 2. j=scalar, the column where the sub section begins > 3. m= number of rows in the sub-section > 4. n= number of columns in the sub-section > > From this the function must output the subsection of the matrix, subA. Does anyone know where I can find a method to do this? On the getting started guide, in the matrix indexing guide and in the function guide (google them). BTW function OUT = foo(A, i, j, m, n) OUT = A(i:i+m, j:j+n) end Oleg
From: Samuel on 27 Feb 2010 12:57 "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hmblsk$kat$1(a)fred.mathworks.com>... > "Samuel " <boo161620(a)yahoo.com> wrote in message <hmbl64$686$1(a)fred.mathworks.com>... > > I am knew at writing matlab code, and I have this problem. Given a 2D matrix, A, of any size [r,c]=size(A), I need to be able to write a function that finds a sub-section of the matrix A from the given inputs, > > 1. i=scalar, the row where the sub section begins, > > 2. j=scalar, the column where the sub section begins > > 3. m= number of rows in the sub-section > > 4. n= number of columns in the sub-section > > > > From this the function must output the subsection of the matrix, subA. Does anyone know where I can find a method to do this? > > On the getting started guide, in the matrix indexing guide and in the function guide (google them). > > BTW > > function OUT = foo(A, i, j, m, n) > OUT = A(i:i+m, j:j+n) > end > > Oleg Thanks, I am having this problem though when I test the function. with A = 1 2 3 4 17 5 6 7 8 18 9 10 11 12 19 13 14 15 16 20 I would like to take out subA=(11, 12; 15, 16), so i=3, j=3, m=2, and n=2. I get the message index is out of bounds. Which I am assuming is because there is not 5 rows in my current A.
From: Oleg Komarov on 27 Feb 2010 13:07 "Samuel " > "Oleg Komarov" > > "Samuel " > > > I am knew at writing matlab code, and I have this problem. Given a 2D matrix, A, of any size [r,c]=size(A), I need to be able to write a function that finds a sub-section of the matrix A from the given inputs, > > > 1. i=scalar, the row where the sub section begins, > > > 2. j=scalar, the column where the sub section begins > > > 3. m= number of rows in the sub-section > > > 4. n= number of columns in the sub-section > > > > > > From this the function must output the subsection of the matrix, subA. Does anyone know where I can find a method to do this? > > > > On the getting started guide, in the matrix indexing guide and in the function guide (google them). > > > > BTW > > > > function OUT = foo(A, i, j, m, n) > > OUT = A(i:i+m, j:j+n) > > end > > > > Oleg > > > > Thanks, I am having this problem though when I test the function. > > with > A = > 1 2 3 4 17 > 5 6 7 8 18 > 9 10 11 12 19 > 13 14 15 16 20 > > I would like to take out subA=(11, 12; 15, 16), so i=3, j=3, m=2, and n=2. I get the message index is out of bounds. Which I am assuming is because there is not 5 rows in my current A. In fact I'm bad at math: > > OUT = A(i:i+m, j:j+n) should be OUT = A(i:i+m-1, j:j+n-1) Oleg
From: Matt Dunham on 27 Feb 2010 13:49 "Samuel " <boo161620(a)yahoo.com> wrote in message <hmbll5$5h9$1(a)fred.mathworks.com>... > Given a 2D matrix A, I need to write a function that displays a subsection of the matrix subA given the following inputs: > A – A 2-D matrix. [r,c] = size(A) where r>=i+m and c>=j+n > i – An integer scalar. A row number in A were the requested subsection begins. > j – An integer scalar. A column number in A were the requested subsection > begins. > m – the number of rows in the subsection > n – the number of column in the subsection > Anybody have any ideas on where I can find more information on this or how I can write this code? Thanks for all your help! subA = A(i:i+m-1, j:j+n-1)
|
Next
|
Last
Pages: 1 2 Prev: Real-Time excel data updated in Matlab Next: Adding Corruptions to AVI Videos |