Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Matrix question

Matrix question

Matrix question


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.

RE: Matrix question

Yes, nested for loops will do the trick. Very simple to program in Matlab.


RE: Matrix question


Can you please inform me on what nested for loops refers to and how it can be used.


I do not have access to my computer that has Matlab installed until the new year so I will try and help you however I can.

It seems like you are asking two questions. To answer you first questions regarding summing every 23 rows of each column? If [A] is your 48 x 88 matrix.

for j=1:88
    for i=1:26

May I ask what you are using Matlab for? I am a structural engineer and I have programmed my own finite element routine and I am in the process of programming steel and concrete design modules. I have access to certified finite element, steel and concrete design programmes, I just feel more assured when I have programmed the logic myself.

RE: Matrix question

you have it

RE: Matrix question

Given the small size of your matrix, a vectorized approach would be most elegant and quickest.  Why not give the CSSMers a holiday golfing problem?

- Steve

RE: Matrix question

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.

Thank you very much to all of you, your help is highly appreciated.
I wish you a great 2009!

RE: Matrix question

OK, This is what I *think* you are asking...

% start with 48 x 88 matrix, A
% add col 1 to col 23, col 2 to col 24 ... col 66 to 88

B = A(:,1:66) + A(:,23:88)

% this gives a 48 x 66 matrix
% sum the columns of B and find 100/sum

C = 100./sum(B);

% this gives a 1 x 66 matrix

Now this is what I don't understand. When you say multiply by the elements of the "original" matrix, do you mean matrix A or matrix B. It won't work for matrix A!

D = B*diag(C);
% D is 48 x 66

Of course you can put all this into 1 line of code, but I have split it up to make it more obvious.


Dr Michael F Platten

RE: Matrix question

Thank you for all the help! I really wish you all have a great year!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close