asked on # Loop with matrices. Please help me!

Hello everyone.

Please I really need help.

I have a matrix that I want to square (multiplying it by itself).

and then I'm gonna add the value of each row of this matrix, and then add the value of this column and divide each value by the total.

Look at this picture and you will understand what I mean.

I need a code to repeat this process until the difference in the weight is < 0.01 (probably using loops).

Im using this code to square the matrices:

and thanks in advance!

Please I really need help.

I have a matrix that I want to square (multiplying it by itself).

and then I'm gonna add the value of each row of this matrix, and then add the value of this column and divide each value by the total.

Look at this picture and you will understand what I mean.

I need a code to repeat this process until the difference in the weight is < 0.01 (probably using loops).

Im using this code to square the matrices:

```
Dim xArray As Variant, zArray As Variant
Dim Fn As Object
Set Fn = Application.WorksheetFunction
xArray = Range("g11:j14").Value
zArray = Fn.MMult(xArray, xArray)
ActiveCell.Resize(4, 4).Value = zArray
```

Please help me!and thanks in advance!

VBAMicrosoft Excel

What is the "difference in the weights"?

repeat until all the weight differences in two adjacent sets are < .001 or until a single comparison is < .001?

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

rwheeler23

Repeat until the weight differences in two adjacent sets are < 0.001

Which means

A-a < 0.001 and B-b <0.001 and C-c <0.001 and D-d<0.001

Which means

A-a < 0.001 and B-b <0.001 and C-c <0.001 and D-d<0.001

You could set up a formula that checks that

Then, select two adjacent blocks and the checker cell and do a fill down, dragging the selection by the lower right corner until the checker value equals True.

```
=And((L15-L9)<.001,(L16-L10)<.001,(L17-L11)<.001,(L18-L12)<.001)
```

Then, select two adjacent blocks and the checker cell and do a fill down, dragging the selection by the lower right corner until the checker value equals True.

What I need is a loop that keeps squaring the matrix until the difference between the weight of the squared matrix and the weight of the previous matrix is < 0.001. That's what I mean bro.

I already know the code to square the matrix. but I dont know how to create a loop that keeps squaring the matrices.

Thanks in advance.

I already know the code to square the matrix. but I dont know how to create a loop that keeps squaring the matrices.

Thanks in advance.

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a question
Are you using my workbook?

Im using a command button in a userform

Your help has saved me hundreds of hours of internet surfing.

fblack61

Did you look at my workbook?

The code assumes a certain configuration of cells to start. If your worksheet does not have that configuration, I would expect the code to fail.

The code assumes a certain configuration of cells to start. If your worksheet does not have that configuration, I would expect the code to fail.

Oh, my bad. It's working perfectly!! thank you so much indeed!!

1 last request, please. I want to record the results of the last weights in a fixed range of cells.

I mean no matter how I change the values of the matrix. after the loop ends, I want the results of the last weights recorded in some fixed range of cells. Let's say cells (O6:O9). can you please help me? and thank you a lot!!! you are truly a life saver!

1 last request, please. I want to record the results of the last weights in a fixed range of cells.

I mean no matter how I change the values of the matrix. after the loop ends, I want the results of the last weights recorded in some fixed range of cells. Let's say cells (O6:O9). can you please help me? and thank you a lot!!! you are truly a life saver!

That is a new feature, so that should be a new question.

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

and can you plz show me what changes do I need to make to the code in case I wanted to change the matrix into 5x5?

Thanks a lot in advance.

Thanks a lot in advance.

alright I will post a new question, but I need you to answer it please <3. thanks a lot

Big thanks to aikimark for his great help!

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat

William Peck