After long and grueling hours laboring alongside my father, I was able to devise a new program that can generate a 3x3 magic matrix in Matlab. Alright! Yay! This working program differs a bit from the failed one last week in approach, but more on that later. The real good news is that after the last several weeks, I'm now comfortable working in Matlab and have familiarized myself with the basic commands and structures I need to program in it. Why is this good news? Weelll, now I'm ready to move into the next part of my project! In the near future, I anticipate actually working with stock market prices. Then I'll be one step closer to creating my final model. So hold on tight everyone. The ride's only beginning. Whoo hoo!
From that bit of code, I get the following:
mat =
1 5 9
1 6 8
2 4 9
2 5 8
2 6 7
3 4 8
3 5 7
4 5 6
Then, the program finds how many times each digit appears in the set of combinations:
generating:
rept =
2 3 2 3 4 3 2 3 2
Now, you may be wondering why it's important to find out how many times each digit appears in the set of combinations adding to 15. Take a look at the magic matrix again:
Notice how the middle number must add in 4 ways in combination with other numbers to 15? Up, down, and twice diagonally. Now look at the corner numbers. They all have to add to 15 in 3 ways, right? By finding out how many times a digit appears in the set of combinations summing to 15, we can figure out which numbers have to go where in the magic matrix!
...Which is exactly what this program does:
Notice how the middle number must add in 4 ways in combination with other numbers to 15? Up, down, and twice diagonally. Now look at the corner numbers. They all have to add to 15 in 3 ways, right? By finding out how many times a digit appears in the set of combinations summing to 15, we can figure out which numbers have to go where in the magic matrix!
...Which is exactly what this program does:
and I get this matix:
mym =
2 9 4
7 5 3
6 1 8
Now just to check. Do the rows, columns, and diagonals all add to fifteen? Yep, they sure do.
Tadaa!
Amazing! And I liked your little joke. Congrats on your acceptance, by the way.
ReplyDelete