You might be wondering why I'm back so soon.
As I promised in the last post, I've been working on making the 3x3 magic square from scratch in Matlab. Matlab has this cool feature that allows you to write and save your own functions and programs as ".m" files that you can then run within the Matlab command window. So, to make my magic square algorithm, I'm writing these ".m" files.Guiding me with this process is my dear old dad, the resident Matlab expert. Here's what we've got so far.
In a file I've meaningfully dubbed "akfasld.m," the following is found:
I won't bore you with explanations of every line, but this is essentially a program that lists conditions for building a 3x3 matrix, "mat." Supposedly, akfasld should make a 3x3 magic matrix. Let's see what happens when I run it.
I get the following: mat =
1 5 9
2 6 7
3 8 4
Hmm...
The rows all add up to 15 like they're supposed to, but what about the columns and diagonals? Oh snap. They don't add to 15 at all!
It appears I've managed to determine the row numbers that make the sum of each row 15, but I've neglected the orders in which the rows and the numbers within them should appear. Now I have to somehow shuffle the rows and their numbers around so that sums of the columns and diagonals equal the rows.
Err...I'll save that for next week.
Until then, have a nice weekend!
Chinita de mi corazón, te felicito por tu trabajo fantástico.
ReplyDeleteHacer magia Nro 1 es lo que has hecho con tu trabajo. Te animo a seguir y lograr todo lo que te has propuesto. Quisera que seas la futura ministra de economía de USA con tanta profecía autocumplida! Un abrazo, Sra Slebos