Results 1 to 8 of 8

Math Help - Matrix problem in Matlab

  1. #1
    Newbie
    Joined
    Dec 2008
    Posts
    3

    Matrix problem in Matlab

    Greetings,

    I have a 48x88 matrix and I need to sum the 1st element to the 23rd, the 2nd element to the 24th, etc until the 66th to the 88th (always using a 22 interval).
    Then I have to divide 100 by the sum of each column. The result will be multiplied by each element of that same column.

    What is the most effective way to do this? Nested for functions?
    This is not an undergraduate college question.

    Thank you for your replies. I appreciate them.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901
    Quote Originally Posted by Tweat View Post
    Greetings,

    I have a 48x88 matrix and I need to sum the 1st element to the 23rd, the 2nd element to the 24th, etc until the 66th to the 88th (always using a 22 interval).
    Then I have to divide 100 by the sum of each column. The result will be multiplied by each element of that same column.

    What is the most effective way to do this? Nested for functions?
    This is not an undergraduate college question.

    Thank you for your replies. I appreciate them.
    66 loops going from 1 to 23 in steps of 1.

    x=0
    For i = 1:1:23
    x=x+A(i)

    x=0
    For i = 2:1:24
    x=x+A(i)

    A bit of copying and pasting and it shouldn't be too bad :P.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by Tweat View Post
    Greetings,

    I have a 48x88 matrix and I need to sum the 1st element to the 23rd, the 2nd element to the 24th, etc until the 66th to the 88th (always using a 22 interval).
    This does not specify what you want done very clearly, is this for each row?

    Then I have to divide 100 by the sum of each column. The result will be multiplied by each element of that same column.
    Is this for the original matrix?

    .
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by Mush View Post
    66 loops going from 1 to 23 in steps of 1.

    x=0
    For i = 1:1:23
    x=x+A(i)

    x=0
    For i = 2:1:24
    x=x+A(i)

    A bit of copying and pasting and it shouldn't be too bad :P.
    Since dim(A) is [48,88] this is a trifle odd, using a single index accesses the array down the columns one after the other.

    .
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2008
    Posts
    3
    Hi,

    Sorry, I didn't explain myself very well.
    I have to normalize the matrix data and my sample is 48 subjects (number of rows).
    The result of the division (100/sum of the columns with 22 interval) must be multiplicated by the elements of the original matrix.

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901
    Quote Originally Posted by Constatine11 View Post
    Since dim(A) is [48,88] this is a trifle odd, using a single index accesses the array down the columns one after the other.

    .
    Yes indeed, but I'm assuming that the jist of my post was recieved well enough that you could convert my method into one that specifies rows and columns.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by Tweat View Post
    Hi,

    Sorry, I didn't explain myself very well.
    I have to normalize the matrix data and my sample is 48 subjects (number of rows).
    The result of the division (100/sum of the columns with 22 interval) must be multiplicated by the elements of the original matrix.

    Thanks.
    Not the neatest way of doing it but the following script might give you the sums you are looking for (unchecked):

    Code:
    a=rand(48,88);
    ii=1:23; 
    rv=zeros(48,66);
    for offset=0:65
      rv(:,offset+1)=(sum(a(:,ii+offset)')');
    end
    .
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    Dec 2008
    Posts
    3
    Thank you very much to both of you, I will try your suggestion.
    I wish you a great 2009!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. matlab matrix help
    Posted in the Math Software Forum
    Replies: 3
    Last Post: May 18th 2010, 12:21 AM
  2. Matlab data cleaning - cell array to matrix problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 24th 2010, 10:08 AM
  3. Matlab matrix in function
    Posted in the Math Software Forum
    Replies: 2
    Last Post: October 14th 2009, 11:24 PM
  4. Matlab ( Matrix )
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 6th 2009, 01:32 AM
  5. Matlab help ........Matrix
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 4th 2009, 06:05 AM

Search Tags


/mathhelpforum @mathhelpforum