MS Word – Matlab Interface

This is what we use in our labs here at UPC. An interesting feature of Matlab to be able to insert code like text in Microsoft Word, and then execute it.

The idea is like this. Given a problem statement or objective, write your code in the word document, and execute it by pressing Ctrl+Enter. You see the output (of course as long as you dont have ; at the end of command) in blue, and the input in green. This helps in generating answer scripts automatically and there is no need to be wasting time in generating lab session reports! In the screenshot below, you see the things mentioned.

Matlab and Word interface - notebook

Matlab and Word interface - notebook

Yes, the picture is bad quality 😦 so I expect you would want to try it out yourself. Note that, you have the variables used in the document, now available in the Matlab variables list. You can do all your testing in the Matlab window itself, to simplify and check the working of your code or you can use the editor and write m-files for functions, which can then be invoked in the word document. All the standard stuff can be done. Images can be inserted by copying the Figure window and just pasting it back in the appropriate place in the Word document. Newer versions of Matlab do this automatically! 🙂 (I don’t know how new though).

Starting from scratch: While creating the documents, you would just say notebook('filename'). The command is essentially notebook and this will open a word document. Once you are done setting all the questions, and giving hint codes etc. you can save and quit both Matlab and Word.

More Coding: To study and code again, the next time you open this document it will automatically start Matlab, thereby starting the automation server. The unfilled, blank copy can be given to students in document form, to complete and then just post back the doc file which contains the code, and the results. Its perfect for lab sessions, and maybe even for exams.

Found this to be an interesting feature 🙂 which was never used before.

Other features include that you can be in the folder (or add to path) the common functions that you have created and need to use.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s