Learn Two Popular Programming Languages in a Single Volume
Widely used by scientists and engineers, well-established MATLAB® and open-source Octave are similar software programs providing excellent capabilities for data analysis, visualisation, and more. By means of straightforward explanations and examples from different areas in mathematics, engineering, finance, and physics, Essential MATLAB and Octave explains how MATLAB and Octave are powerful tools applicable to a variety of problems.
This text requires no prior knowledge. Self-contained, it allows the reader to use the material whenever needed rather than follow a particular order. Compatible with both languages, the book material incorporates commands and structures that allow the reader to gain a greater awareness of MATLAB and Octave, write their own code, and implement their scripts and programs within a variety of applicable fields. It is always made clear when particular examples apply only to MATLAB or only to Octave, allowing the book to be used flexibly depending on readers’ requirements.
Essential MATLAB and Octave offers an introductory course in MATLAB and Octave programming and is an authoritative resource for students in physics, mathematics, statistics, engineering, and any other subjects that require the use of computers to solve numerical problems.
- Includes brief, simple code that works in both MATLAB and Octave
- Provides exercise sections at the end of each chapter
- Introduces framed examples and discussions with a scientific twist
I got pinged this screenshot from a friend that saw "Essential MATLAB and Octave" being included in the CERN Document Server!
Well, it is not a surprise anymore that I am currently working on writing a second book. First time round it was a book motivated for the use of Matlab and its counterpart Octave in the area of simulations suitable for students of physics, mathematics, biology, economics and engineering. It was a very good experience, and it seems that I enjoyed it so much that I am embarking in another project.
This time round it is a book more geared up towards more seasoned programmers, developers and business people who are interested in learning more about data science and analytics. The language of choice this time round is Python, and why not? It seems to be a popular choice and goes well with other activities I have recently been involved with.
I was, once again, pleasantly surprised that my publisher has already created an entry in their site to advertise the book. The date for delivery is currently utterly wrong, but please do keep an eye and I shall try to update you as to how the writing goes.”Read
I am an avid user of Markdown via Mou and R Markdown (with RStudio). The facility that the iPython Notebook offers in combining code and text to be rendered in an interactive webpage is the choice for a number of things, including the 11-week Data Science course I teach at General Assembly.
Markup for Fast Data Science Publication
A central lesson of science is that to understand complex issues (or even simple ones), we must try to free our minds of dogma and to guarantee the freedom to publish, to contradict, and to experiment. — Carl Sagan in Billions & Billions: Thoughts on Life and Death at the Brink of the Millennium
As data scientists, it's easy to get bogged down in the details. We're busy implementing Python and R code to extract valuable insights from data, train effective machine learning models, or put a distributed computation system together. Many of these tasks, especially those relating to data ingestion or wrangling, are time-consuming but are the bread and butter of the data scientist's daily grind. What we often forget, however, is that we must not only be data engineers, but also contributors to the data science corpus of knowledge.
If a data product derives its value from data and generates more data in return, then a data scientist derives their value from previously published works and should generate more publications in return. Indeed, one of the reasons that Machine Learning has grown ubiquitous (see the many Python-tagged questions related to ML on Stack Overflow) is thanks to meticulous blog posts and tools from scientific research (e.g. Scikit-Learn) that enable the rapid implementation of a variety of algorithms. Google in particular has driven the growth of data products by publishing systems papers about their methodologies, enabling the creation of open source tools like Hadoop and Word2Vec.
By building on a firm base for both software and for modeling, we are able to achieve greater results, faster. Exploration, discussion, criticism, and experimentation all enable us to have new ideas, write better code, and implement better systems by tapping into the collective genius of a data community. Publishing is vitally important to keeping this data science gravy train on the tracks for the foreseeable future.
In academia, the phrase "publish or perish" describes the pressure to establish legitimacy through publications. Clearly, we don't want to take our rule as authors that far, but the question remains, "How can we effectively build publishing into our workflow?" The answer is through markup languages - simple, streamlined markup that we can add to plain text documents that build into a publishing layout or format. For example, the following markup languages/platforms build into the accompanying publishable formats:
- Markdown → HTML
- iPython Notebook (JSON + Markdown) → Interactive Code
- reStructuredText + Sphinx → Python Documentation, ReadTheDocs.org
- AsciiDoc → ePub, Mobi, DocBook, PDF
- LaTeX → PDF
The great thing about markup languages is that they can be managed inline with your code workflow in the same software versioning repository. Github goes even further as to automatically render Markdown files! In this post, we'll get you started with several markup and publication styles so that you can find what best fits into your workflow and deployment methodology.
Markdown is the most ubiquitous of the markup languages we'll describe in this post, and its simplicity means that it is often chosen for a variety of domains and applications, not just publishing. Markdown, originally created by John Gruber, is a text-to-HTML processor, where lightweight syntactic elements are used instead of the more heavyweight HTML tags. Markdown is intended for folks writing for the web, not designing for the web, and in some CMS systems, it is simply the way that you write, no fancy text editor required.
Markdown has seen special growth thanks to Github, which has an extended version of Markdown, usually referred to as "Github-Flavored Markdown." This style of Markdown extends the basics of the original Markdown to include tables, syntax highlighting, and other inline formatting elements. If you create a Markdown file in Github, it is automatically rendered when viewing files on the web, and if you include a README.md in a directory, that file is rendered below the directory contents when browsing code. Github Issues are also expected to be in Markdown, further extended with tools like checkbox lists.
Markdown is used for so many applications it is difficult to name them all. Below are a select few that might prove useful to your publishing tasks.
- Jekyll allows you to create static websites that are built from posts and pages written in Markdown.
- Github Pages allows you to quickly publish Jekyll-generated static sites from a Github repository for free.
- Silvrback is a lightweight blogging platform that allows you to write in Markdown (this blog is hosted on Silvrback).
- Day One is a simple journaling app that allows you to write journal entries in Markdown.
- iPython Notebook expects Markdown to describe blocks of code.
- Stack Overflow expects questions, answers, and comments to be written in Markdown.
- MkDocs is a software documentation tool written in Markdown that can be hosted on ReadTheDocs.org.
- GitBook is a toolchain for publishing books written in Markdown to the web or as an eBook.
There are also a wide variety of editors, browser plugins, viewers, and tools available for Markdown. Both Sublime Text and Atom support Markdown and automatic preview, as well as most text editors you'll use for coding. Mou is a desktop Markdown editor for Mac OSX and iA Writer is a distraction-free writing tool for Markdown for iOS. (Please comment your favorite tools for Windows and Android). For Chrome, extensions like Markdown Here make it easy to compose emails in Gmail via Markdown or Markdown Preview to view Markdown documents directly in the browser.
Clearly, Markdown enjoys a broad ecosystem and diverse usage. If you're still writing HTML for anything other than templates, you're definitely doing it wrong at this point! It's also worth including Markdown rendering for your own projects if you have user submitted text (also great for text-processing).
$ pip install markdown bleach
Then create a markdown parsing function as follows:
import bleach from markdown import markdown def htmlize(text): """ This helper method renders Markdown then uses Bleach to sanitize it as well as converting all links in text to actual anchor tags. """ text = bleach.clean(text, strip=True) # Clean the text by stripping bad HTML tags text = markdown(text) # Convert the markdown to HTML text = bleach.linkify(text) # Add links from the text and add nofollow to existing links return text
Given a markdown file
test.md whose contents are as follows:
# My Markdown Document For more information, search on [Google](http://www.google.com). _Grocery List:_ 1. Apples 2. Bananas 3. Oranges
The following code:
>>> with open('test.md', 'r') as f: ... print htmlize(f.read())
Will produce the following HTML output:
<h1>My Markdown Document</h1> For more information, search on <a href="http://www.google.com" rel="nofollow">Google</a>. <em>Grocery List:</em> <ol> <li>Apples</li> <li>Bananas</li> <li>Oranges</li> </ol>
Hopefully this brief example has also served as a demonstration of how Markdown and other markup languages work to render much simpler text with lightweight markup constructs into a larger publishing framework. Markdown itself is most often used for web publishing, so if you need to write HTML, then this is the choice for you!
To learn more about Markdown syntax, please see Markdown Basics.
iPython Notebook is an web-based, interactive environment that combines Python code execution, text (marked up with Markdown), mathematics, graphs, and media into a single document. The motivation for iPython Notebook was purely scientific: How do you demonstrate or present your results in a repeatable fashion where others can understand the work you've done? By creating an interactive environment where code, graphics, mathematical formulas, and rich text are unified and executable, iPython Notebook gives a presentation layer to otherwise unreadable or inscrutable code. Although Markdown is a big part of iPython Notebook, it deserves a special mention because of how critical it is to the data science community.
iPython Notebook is interesting because it combines both the presentation layer as well as the markup layer. When run as a server, usually locally, the notebook is editable, explorable (a tree view will present multiple notebook files), and executable - any code written in Python in the notebook can be evaluated and run using an interactive kernel in the background. Math formula written in LaTeX are rendered using MathJax. To enhance the delivery and shareability of these notebooks, the NBViewer allows you to share static notebooks from a Github repository.
iPython Notebook comes with most scientific distributions of Python like Anaconda or Canopy, but it is also easy to install iPython with pip:
$ pip install ipython
iPython itself is an enhanced interactive Python shell or REPL that extends the basic Python REPL with many advanced features, primarily allowing for a decoupled two-process model that enables the notebook. This process model essentially runs Python as a background kernel that receives execution instructions from clients and returns responses back to them.
To start an iPython notebook execute the following command:
$ ipython notebook
This will start a local server at
and automatically open your default browser to it. You'll start in the "dashboard view", which shows all of the notebooks available in the current working directory. Here you can create new notebooks and start to edit them. Notebooks are saved as .ipynb files in the local directory, a format called "Jupyter" that is simple JSON with a specific structure for representing each cell in the notebook. The Jupyter notebook files are easily reversioned via Git and Github since they are also plain text.
To learn more about iPython Notebook, please see the iPython Notebook documentation.
reStructuredText is an easy-to-read plaintext markup syntax specifically designed for use in Python docstrings or to generate Python documentation. In fact, the reStructuredText parser is a component of Docutils, an open-source text processing system that is used by Sphinx to generate intelligent and beautiful software documentation, in particular the native Python documentation.
Python software has a long history of good documentation, particularly because of the idea that batteries should come included. And documentation is a very strong battery! PyPi, the Python Package Index, ensures that third party packages provide documentation, and that the documentation can be easily hosted online through Python Hosted. Because of the ease of use and ubiquity of the tools, Python programmers are known for having very consistently documented code; sometimes it's hard to tell the standard library from third party modules!
In How to Develop Quality Python Code, I mentioned that you should use Sphinx to generate documentation for your apps and libraries in a docs directory at the top-level. Generating reStructuredText documentation in a docs directory is fairly easy:
$ mkdir docs $ cd docs $ sphinx-quickstart
The quickstart utility will ask you many questions to configure your documentation. Aside from the project name, author, and version (which you have to type in yourself), the defaults are fine. However, I do like to change a few things:
... > todo: write "todo" entries that can be shown or hidden on build (y/n) [n]: y > coverage: checks for documentation coverage (y/n) [n]: y ... > mathjax: include math, rendered in the browser by MathJax (y/n) [n]: y
Similar to iPython Notebook, reStructured text can render LaTeX syntax mathematical formulas. This utility will create a Makefile for you; to generate HTML documentation, simply run the following command in the docs directory:
$ make html
The output will be built in the folder _build/html where you can open the index.html in your browser.
While hosting documentation on Python Hosted is a good choice, a better choice might be Read the Docs, a website that allows you to create, host, and browse documentation. One great part of Read the Docs is the stylesheet that they use; it's more readable than older ones. Additionally, Read the Docs allows you to connect a Github repository so that whenever you push new code (and new documentation), it is automatically built and updated on the website. Read the Docs can even maintain different versions of documentation for different releases.
Note that even if you aren't interested in the overhead of learning reStructuredText, you should use your newly found Markdown skills to ensure that you have good documentation hosted on Read the Docs. See MkDocs for document generation in Markdown that Read the Docs will render.
To learn more about reStructuredText syntax, please see the reStructuredText Primer.
When writing longer publications, you'll need a more expressive tool that is just as lightweight as Markdown but able to handle constructs that go beyond simple HTML, for example cross-references, chapter compilation, or multi-document build chains. Longer publications should also move beyond the web and be renderable as an eBook (ePub or Mobi formats) or for print layout, e.g. PDF. These requirements add more overhead, but simplify workflows for larger media publication.
Writing for O'Reilly, I discovered that I really enjoyed working in AsciiDoc - a lightweight markup syntax, very similar to Markdown, which renders to HTML or DocBook. DocBook is very important, because it can be post-processed into other presentation formats such as HTML, PDF, EPUB, DVI, MOBI, and more, making AsciiDoc an effective tool not only for web publishing but also print and book publishing. Most text editors have an AsciiDoc grammar for syntax highlighting, in particular sublime-asciidoc and Atom AsciiDoc Preview, which make writing AsciiDoc as easy as Markdown.
AsciiDoctor is an AsciiDoc-specific toolchain for building books and websites from AsciiDoc. The project connects the various AsciiDoc tools and allows a simple command-line interface as well as preview tools. AsciiDoctor is primarily used for HTML and eBook formats, but at the time of this writing there is a PDF renderer, which is in beta. Another interesting project of O'Reilly's is Atlas, a system for push-button publishing that manages AsciiDoc using a Git repository and wraps editorial build processes, comments, and automatic editing in a web platform. I'd be remiss not to mention GitBook which provides a similar toolchain for publishing larger books, though with Markdown.
Editor's Note: GitBook does support AsciiDoc.
To learn more about AsciiDoc markup see AsciiDoc 101.
If you've done any graduate work in the STEM degrees then you are probably already familiar with LaTeX to write and publish articles, reports, conference and journal papers, and books. LaTeX is not a simple markup language, to say the least, but it is effective. It is able to handle almost any publishing scenario you can throw at it, including (and in particular) rendering complex mathematical formulas correctly from a text markup language. Most data scientists still use LaTeX, using MathJax or the Daum Equation Editor, if only for the math.
If you're going to be writing PDFs or reports, I can provide two primary tips for working with LaTeX. First consider cloud-based editing with Overleaf or ShareLaTeX, which allows you to collaborate and edit LaTeX documents similarly to Google Docs. Both of these systems have many of the classes and stylesheets already so that you don't have to worry too much about the formatting, and instead just get down to writing. Additionally, they aggregate other tools like LaTeX templates and provide templates of their own for most document types.
My personal favorite workflow, however, is to use the Atom editor with the LaTeX package and the LaTeX grammar. When using Atom, you get very nice Git and Github integration - perfect for collaboration on larger documents. If you have a TeX distribution installed (and you will need to do that on your local system, no matter what), then you can automatically build your documents within Atom and view them in PDF preview.
A complete tutorial for learning LaTeX can be found at Text Formatting with LaTeX.
Software developers agree that testing and documentation is vital to the successful creation and deployment of applications. However, although Agile workflows are designed to ensure that documentation and testing are included in the software development lifecycle, too often testing and documentation is left to last, or forgotten. When managing a development project, team leads need to ensure that documentation and testing are part of the "definition of done."
In the same way, writing is vital to the successful creation and deployment of data products, and is similarly left to last or forgotten. Through publication of our work and ideas, we open ourselves up to criticism, an effective methodology for testing ideas and discovering new ones. Similarly, by explicitly sharing our methods, we make it easier for others to build systems rapidly, and in return, write tutorials that help us better build our systems. And if we translate scientific papers into practical guides, we help to push science along as well.
Don't get bogged down in the details of writing, however. Use simple, lightweight markup languages to include documentation alongside your projects. Collaborate with other authors and your team using version control systems, and use free tools to make your work widely available. All of this is possible becasue of lightweight markup languages, and the more profecient you are at including writing in your workflow, the easier it will be to share your ideas.
This post is particularly link-heavy with many references to tools and languages. For reference, here are my preferred guides for each of the Markup languages discussed:
- Markdown Basics
- the iPython Notebook documentation
- reStructuredText Primer
- AsciiDoc 101
- Text Formatting with LaTeX.
Books to Read
- Instant Markdown by Arturo Herrero
- IPython Interactive Computing and Visualization Cookbook by Cyrille Rossant
Special thanks to Rebecca Bilbro for editing and contributing to this post. Without her, this would certainly have been much less readable!
As always, please follow @DistrictDataLab on Twitter and subscribe to this blog by clicking the Subscribe button on the blog home page.
It has been a long wait, but finally today I got my hands on the physical version of my book. So pleased.
It is available from the publishers
I am very pleased to see that the Mathworks has now added my book "Essential MATLAB and Octave" to their MathWorks Book Program Member Support Web site. They have now made available a page for the book and it can be reached here.
|About Us | Resources | Textbooks | Featured Authors | Customer Service | Related Books|
in your shopping cart
for 25% SAVINGS
Offer expires December 3.
Discount codes exclude eBooks.
|You May Also Be Interested in These Related Books
Fischer-Cripps Student Companion Set
To apply your discount, enter LZN17 in your shopping cart,
or call 800-272-7737 or +44 (0) 1235 400 524.This offer expires December 3. Promo codes do not apply to eBooks.Thank you for being part of the CRC Press community!
These exclusive discounts are only available in our email and print promotions.
Take full advantage of your insider savings and complimentary shipping when you buy directly from CRCPress.com.
In the UK it will be out around the 4th of December so keep an eye on the Amazon page.
I also want to share with you an endorsement from Prof Sabino Chávez-Cerda from INAOE:
This is an excellent book for anyone approaching Matlab or Octave for the first time. The pleasant language used throughout the book creates the sensation of having the author by your side. If you have the intention of self-learning the basics Matlab from where you can start doing big technical or scientific projects this is the book that will help you to get your goals.
This is friendly a hands on practical self-study guide to Matlab and Octave for the beginner. With words of advice and caution. This is not what could be considered formally a reference book, for that purpose one have the help within any of both programs, but this is a book that will take teach how to walk to be able to run on your own. An interesting feature are the examples used to explain the use of functions and operations. They appear to be simple but it is years of experience that show the opposite, they can be the building blocks of more complex programmes.
The author presents without complicated language in the first three chapters the necessary commands to start solving simple mathematical problems. In science an engineering results are usually displayed graphically in different kind of plots. One of the aspects that I want to highlight regarding this book is that, compared to other similar texts on Octave and Matlab, the author introduces at an early stage how to produce line and surface plots with Matlab and Octave. It is very attractive to students to be able to quickly produce plots with scientific journal quality. Having this tool is like having a springboard that is complemented with the commands coming in the next chapter.
Chapter 5 presents programming structures common to high level programming languages explaining the particularities for Matlab and Octave. Finally in Chapter 6 the author presents examples form different disciplines exposed in a very and straight forward way that once they are reproduced by the reader, he or she will have the confidence on working problems of their own disciplines being these easy or with a certain level of complexity.
The side help are great as they can also work as virtual bookmarks when required to comeback to the explanation of a Matlab or Octave command. It has been shown in psychology experiments that this kind of features in a paper book are kept in memory and that can be retrieved more easily when needed.
There are a very few books devoted to the learning of Octave, although this might be because its high compatibility with Matlab or lack of knowledge of its existence. The main difference between these two is that Matlab is a commercial software and Octave is an open source software. On the technical side between Matlab and Octave there are a few commands that are different but this book helps you highlighting the most useful ones. Introducing Octave, is a plus for this book in developing countries where access to software with prices above one thousand dollars are simply beyond of considering even for universities.
I have found this obstacle in Mexican and Brazilian Universities where I was invited to teach a course on Computational Physics, the universities did not own Matlab and did not have the resources to buy it. I am a Matlab user but knowing of Octave I suggested to get it and install it, they were so happy as they had two things at once the course and a software that could be used for future generations.
The book is just the right size at above the two hundred pages that are enlarged by the friendly format that otherwise would be below the two hundred pages line. The density and the writing style of the text makes it easy to read and grab the information intended to be learned. It has references to recent literature and also provides information about relevant websites.
In conclusion, the book Essential Matlab and Octave, a Beginners handbook is an easy read that will provide the necessary tools to begin working with Matlab or Octave in a short period of time, that with some dedication it can be of no more than two weeks.
Prof. Sabino Chávez-Cerda
INAOE, México, OSA Fellow
The publication date of "Essential MATLAB and Octave" is getting closer and closer. I would like to use this as an opportunity to share yet another endorsement, this time from Dr Hiram Luna-Munguia from the Department of Neurology at the University of Michigan:
This well-written book is a must-have for those people starting to solve numerical problems in Matlab or Octave. Since the beginning the reader will appreciate that the book´s major goal is to describe the essential aspects of both software without discrediting or highlighting the use of any of them. Page by page you will find clear explanations describing the way you should communicate with each software. The set of homework problems given at the end of each chapter makes the book even more dynamic.
Students and experts will warmly welcome Essential Matlab and Octave: A Beginner's Handbook into their libraries. I highly recommend it as an excellent reference tool.
I have received very good news from CRC Press in regards to the publication of my book "Essential Matlab and Octave": The publication date for the book in the US is November 13th, and the UK following after one or two week.
Also, the endorsements for the book are very good and I thought of sharing one from Dr Shashank Virmani from the Brunel University, UK:
"Essential Matlab and Octave" is a superb introductory textbook for those interested in learning how to solve scientific, engineering, and mathematical problems using two of the most popular mathematical programming tools available --- Matlab and Octave.
The book assumes almost no prior experience with programming or scientific programming, and carefully takes the reader step-by-step through the use the of the two languages for solving increasingly complex problems. It begins with elementary tasks such as the evaluation of simple functions, takes the reader through the basics of plotting figures and programming syntax, leading up to a chapter of more sophisticated examples of problems to suit a diverse range of tastes, including linear algebra applications, the solution of differential equations in physics and biology, signal processing, and problems in mathematical finance.
Dr. Rogel-Salazar has put a huge amount of effort into making the book accessibly and user-friendly in a way that makes it suitable even for the most novice of programmers. The layout of the book is used very effectively with boxes that give clear and concise example programmes and the use of side notes to point out where differences can occur between Matlab and Octave, and to provide references and additional information.
Just the right balance of content is chosen for a beginner to quickly reach a stage where they can begin to write useful programmes of their own. Enough detail is included to point out the power and major stumbling blocks, without overburdening the reader with too much detail on the more subtle aspects that they can only come to appreciate after further experience of programming. This helps the textbook fill a useful gap in the market, and make it an excellent companion to introductory courses on scientific computation in degree programmes, as well as an accessible but concise guide to anyone learning how to use such tools by themselves”
With the up-coming publishing of my book Essential Matlab and Octave, it is great to star receiving endorsements from practitioners and lecturers that have had a chance to review the book. Here I have the pleasure of sharing one:
From: Dr Alan McCall, University of Hertfordshire.
The text provides a clear and easy paced introduction to Matlab and Octave. The presentation is example led and contains plenty of useful applications drawn from mathematics, physics and engineering. This beginner’s handbook will suit a broad scientific readership.
- The in-parallel coverage of Matlab and Octave.
- All key software features are covered in a concise and careful manner.
- Includes many of the common scientific computing tasks for which the software can be used.
- Contains a wide range of applications from linear algebra, portfolio analysis, differential equations, signal processing, wave motion and quantum mechanics.
- Provides lots of useful practical tips not found in other texts.
- The numerous in text examples and end of chapter exercises encourage learning by doing.
- A suitable text for a short course or a useful reference for self-study.
I am super excited as I have just received what seem to be the final corrections from the CRC Press copyeditors in regards to my book "Essential MATLAB and Octave". The total corrections amounts to one (1) comma! Not bad!
You can have a look at the CRC Press for the book here.
In Amazon, you can find the book here.”Read
I have now updated my Author Page at CRC Press. Take a look here.
I am very pleased to announce that I have submitted the final version of my book entitled "Essential MATLAB and Octave" to CRC Press. Also I have seen a preliminary cover, and they indeed have used the figure I proposed.
Not only that, but it seems that Amazon is already using that image!
As probably some of you know, I am currently writing a book about MATLAB and Octave focussed at new comers to both programming and the MATLAB/Octave environments. The book is tentatively entitled "Essential MATLAB and Octave" and I am getting closer and closer to getting the text finished. The next step is preparing exercises and finalising things. My publisher, CRC Press, has been great and I hope the book does well.
I'm aiming to finish things by May and in principle the book will be available from Novemeber or so. The whole process does take a while but I am really looking forward to seeing the finished thing out there.
So, what triggered this post? Well, I have seen the appearance of a site with the book announced. I am not sure if these are usual practices but in any case it is a good thing, don't you think?