Quantitative finance collector
C++ Matlab VBA/Excel Java Mathematica R/Splus Net Code Site Other
Feb 28

Sudoku Spreadsheet Example of Matlab Excel Link

Posted by abiao at 11:52 | Code » Matlab | Comments(1) | Reads(11914)
Sudoku is one of my favorite small games I often have fun with, I save one copy at my gphone and play it whenever I want to take a rest. (most of us may have a wrong impression that Sudoku originated in Japan, no, in America.)

I happened to find Cleve Moler solved Sudoku using recursive backtracking method and the speed is fast, the minor error is it doesn't report an error when the initial 9*9 matrix you give violates Sudoku rules (you can test it later, the code starts to run and returns a result even you give repetitive numbers along a same row or column). Since building a GUI in matlab isn't easy, I choose to build a Sudoku spreadsheet using Matlab Excel link for an example.

Once you install Excel Link module and turn it on, you will notice the short-cuts on the excel menu bar looking like
Open in new window  
intuitively, those buttons stand for "start matlab", "send data to matlab", "retrieve data from matlab", and "execute the matlab command", respectively.

For my case, I first download the Sudoku M code at http://www.mathworks.co.uk/company/newsletters/news_notes/2009/clevescorner.html?s_cid=ACD0210ukTA2&s_v1=8728847_1-BR7DSN, then open an excel file, write down a 9*9 matrix "X"
Open in new window
then define a zone to fetch the calculation result, which should also be 9*9
Open in new window

finally do steps:
<- put data to matlab, MLPutmatrix("X",X)
<- solve the problem in matlab, MLEvalString("X=sudoku(X)")
<- get results from matlab, MLGetMatrix("X","NewX")

result is then retrieved immediately to Sudoku Spreadsheet from matlab
Open in new window

Straightforward to run your Matlab function in excel, isn't it? alternatively you can use Matlab builder for excel.

Tags: ,
The information is top quality, you may see quite a few exclusive things that can't be found on other blogs, really versatile but still very specific!
the sims mobile cheats
Pages: 1/1 First page 1 Final page
Add a comment
Enable HTML
Enable UBB
Enable Emots
Nickname   Password   Optional
Site URI   Email   [Register]