Tag Archives: Tutorial



One of the things that I spend a lot of time doing in Mathematica is creating lists of co-ordinates so that I can export them into structural analysis software, either before or after I've rotated and transformed them through space to mimic a deployable structure.

Most of these methods I've picked up along the way through trawling Stack Exchange which I find a great resource for learning Mathematica, I'm not able to link to all of them as I've hoovered them up into a notebook over a long period of time and not kept all of the original links...

Creating lists.

Frequently I'll create a list of x co-ordinates, then y co-ordinates, then the z co-ordinates.  There are a multitude of ways to do this, a few of the ways to create a list of co-ordinates are linked below:

Other ways of creating lists, could make use of functions.

{0, 2, 4, 6, 8, 10}

{1, 4, 9, 16, 25}

Creating points

And there are dozens of other methods that are available, but once you have your list of x, y, and z co-0rdinates then the next step is to combine them.  You could certainly type them in long hand as below, but the more nodes you have the longer it takes.

You could automate a simple list of co-ordinates like above in a couple of ways:


Both return the same list of co-ordinates:

{{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {3, 0, 0}, {4, 0, 0}, {5, 0, 0}}

Combining lists.

Or you might have created a list of points, the same as the lists x,y, and z at the top of this post and now want to combine them...


Thread[ ] is available and is one of the quicker methods for knitting together lists.

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}


An alternative is  MapThread[ ]


both return.

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}


Transpose[ ]   can be used for nice tidy syntax


If there is a simple 2D set of co-ordinates, then these can be combined using  Inner[ ]


Again for simple 2D lists, the function  Riffle[ ] can be used, but needs to be used in combination with  Partition[ ]

If you're working with multiple lists, then a function called multiRiffle can be written, taken from here.


{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}


Custom functions.

If you only have 2D data points then a function could be written to knit them together, these functions can check to see if the lists are of the same length too which can be beneficial.

{{0, 10}, {1, 11}, {2, 12}, {3, 13}, {4, 14}, {5, 15}, {6, 16}}

Which can be adapted for 3D data points easily enough.

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}

Hopefully this will help someone who's learning Mathematica who's going to be working with data points and co-ordinates a lot.  It seems to be a topic that gets asked a lot on Mathematica Stack Exchange so I thought it would be helpful to try and summarise up in one post.

General Research Tutorial


Part of the work that I've been undertaking on Mathematica is to create a series of sheets that will calculate the geometry of a cable-chain arch with a set of given parameters.  In part I’m interested in how the cable-chain arch can behave as a deployable structure and looking to build on the work of (Li, Vu, & Richard, 2011) to see how practical a cable-chain structure can be made with regards economy, efficiency, and robustness.  Essentially a cable-chain structure is a curved arch that is sub-divided into straight sections, with cables spanning across the base of two struts as can be seen in the figure below.  Simple versions of these types of structures are widely used for the likes of temporary and deployable aircraft hangers to create large open spans.


Now that I’ve got the makings of a simple Mathematica sheet up and running and I’ve taught myself some rudimentary programming and graphics manipulation skills I’ve managed to start to knock together what I feel are some high quality illustrations for my thesis.

I’ve done this with a mixture of Mathematica to create the base diagram, which I save as a PDF.  I then import the PDF into OmniGraffle to annotate the diagram and then export to a PNG file to maintain the transparent background, this figure I can then host for linking into blogs etc.  Below is a sample figure which shows how the number of segments (nSeg) affects the internal area available for habitation within a typical parabolic arch.

Cable Arches

Given that both of my brothers are colour blind and I’ve never done the test, I’m not convinced on my choice of colour schemes, but the good news is that it won’t take long to change if it turns out I’ve made my figures look like something off the set of Austin Powers.

So far I’m finding OmniGraffle quite limited compared to Visio that I’ve been using for my diagrams for perhaps 20 years or so.  I decided to use OmniGraffle though as most of my writing work is done on a Mac, although I also have a PC so I can always create the more complex diagrams on Visio if need be, especially as I’ve managed to get a legitimate copy from work for £12.

I'd love to hear how other engineers and academics approach creating technical figures and sketches on their Macs though, I've a feeling that I'm really missing out on something and there's got to be a much slicker workflow out there.


Li, Y., Vu, K. K., & Richard, J. Y. (2011). Deployable Cable-Chain Structures: Morphology, Structural Response And Robustness Study. Journal for the International Association for Shell and Spatial Structures, 52(168), 83-96.


Teaching Tutorial


One of the reasons that I started this blog was so that I could mess about with embedding some Mathematica files to help with testing out some ideas.  For this to make sense it's easiest if I embed a few simple examples in this blog post.  Now if you want to interact with these examples, I'm afraid you're going to have to download the Wolfram CDF player, which is completely free and works on PC's and Mac's alike.  Imagine it as a sort of PDF viewer but it lets you interact with the files as opposed to a PDF which is typically just a static and lifeless document.

Consider the following equation:

Sin\left( {2x} \right)

Most text books would draw the graph for this over whichever range they deemed to be suitable and then students would try and learn from these dull and boring diagrams.

 Now this is how I was taught maths and in fairness, it's pretty dull and it's difficult to gain any form of intuition as to how it might behave if the 2 became a 3 for example, this is where Mathematica's CDF files come in handy because it has some nice tricks for letting you explore maths in an interactive fashion... let's consider the following equation, from the previous graph most people wouldn't really know how it would affect the graph.

Sin\left( {a.{\rm{ }}x} \right)

But if we crank this through Mathematica we can create a really nice interactive widget that can be shared with anyone for free!  As you change the slider, the graph updates in real time, and if you want to know what number you're changing 'a' to be then simply click the little + sign next to the slider itself to expand the input values beneath it.  In fact if you think that messsing with sliders is far too much like hard work, then simply click the little play button in the top right and the widget will work the sliders for you... sit back and watch the pattern.


If you're not familiar with Mathematica, you may be concerned that this sort of widget is really difficult to create, but actually I'm still on Chapter 3 on the text that I'm working through and the code is incredibly simple to create this kind of interactive learning tool and I've replicated it below to show how few lines of text can create this level of interaction.

Manipulate[ Plot[ Sin[a x], {x, -10, 10}], {a, 1, 5}]

Essentially this code starts with "I want a slider widget", "Plot me a graph of Sin(a.x) over a range of values for x from -10 to 10", then "make the slider vary a from 1 to 5".

Now this seems ok, but the Manipulate command is actually incredibly powerful and with a little more twiddling, high quality interactive 3D plots can be created, so let's consider the following expression.

f{\rm{ }}Sin\left( x \right) + g{\rm{ }}Sin\left( y \right)

This expression has four variables: f,g,x, and y.  Of course, I bet you're dying to know what the graph looks like for this function so you can boost your maths skills...


This is where the CDF player starts to flex its muscles a little, not only can you mess around with the sliders to change the values of f and g... but you can click and rotate the 3D graph itself to get a better view of how you think it's working.  For me this level of interaction is a real opportunity for playing with the maths to help build up a level of intuition and feeling of how the maths will behave.  And once again the code to get it to work is fairly straight forward even for a novice such as myself.

Manipulate[Plot3D[(f ) Sin[ x] + (g)  Sin [y], {x, 1, 10}, {y, 1, 10}], {f, -10, 10}, {g, -10, 10}]

Now here's the rub, a full Mathematica licence is the best part of £1,000 for a lecturer to use, in these hard times that's a lot of money.  But because I carry 'dual' status as I'm studying 2 degrees as well as working full time as a lecturer I was able to pick up a student licence for roughly £80.  Normally the cost for a student licence is a shade over £100 but it is possible to reduce the normal student price by 15% by using the discount code PD1637 at the Wolfram store checkout and I still retain the full functionality of sharing my CDF files via export.

I hope this helps someone, if you've any feedback on this post or would like to ask any questions, please get in touch or leave a comment below.

General Tutorial


Turns out that my web provider now provides a SQL and PHP server with my base package and this was all the incentive I needed to give a self hosted WordPress blog a whirl.  To get a basic blog system up and running literally took me 5 minutes with the free WordPress software and using the export function I was quickly able to copy the few posts over from my free WordPress blog.

Now I have my own hosted service this presents me with several advantages over the free wordpress accounts, but there are two in particular that are attractive to me.  The first one is that I can now embed proper equations into a blog post using LaTeX and MathML by linking it into my equation editor MathType...

By adding in the 'LaTeX for WordPress' plug in for the hosted WordPress, I can now copy equations straight from MathType and paste them directly into my blog by following this procedure.

1.) Open MathType and prepare your equation.

2.) Go to MathType -> Preferences -> Cut and copy preferences; and then select MathML or TeX; then LaTeX 2.09 and later


3.) Highlight the equation in MathType 6.7d and then right click and select copy or press (⌘ + C)

4.) Find the position in your blog post where you want the equation to appear, then paste (⌘ + V)

Following this means that I can embed equations like the one below pretty easily, the only downside that I've found is that if you've colour coded your equation in MathType, none of this formatting will carry over when pasting, but the equations should work and be visible in any browser, certainly the main three and on the iPhones and Android devices that I've worked on so far.

{F_d} = \overbrace {\sum\limits_{j \ge 1} {{\gamma _{G,j}}{\rm{ }}{G_{k,j}}} }^{{\rm{Permanent}}} + \overbrace {{\gamma _p}{\rm{ }}P}^{{\rm{Prestress}}} + \overbrace {{\gamma _{Q,{\rm{ }}1}}{\rm{ }}{Q_{k,{\rm{ }}1}}}^{{\rm{Leading}}{\rm{ Variable}}} + \overbrace {\sum\limits_{i > 1} {{\gamma _{Q,{\rm{ }}i}}{\rm{ }}{\psi _{0,{\rm{ }}i}}{\rm{ }}{Q_{k,{\rm{ }}i}}} }^{{\rm{Other Variable Actions}}}

With minimal tweaking and a little trial and error with the LaTeX code I was able to apply some colour tags to get the equation to look the same as it does in my lecture notes.

{F_d} = \overbrace {\sum\limits_{j \ge 1} {{\gamma _{G,j}}{\rm{ }}{G_{k,j}}} }^{{\rm{\color{Red} {Permanent}}}} + \overbrace {{\gamma _p}{\rm{ }}P}^{{\rm{\color{Red}{Prestress}}}} + \overbrace {{\gamma _{Q,{\rm{ }}1}}{\rm{ }}{Q_{k,{\rm{ }}1}}}^{{\rm{\color{Red}{Leading}{\rm{\color{Red}{ Variable}}}}}} + \overbrace {\sum\limits_{i > 1} {{\gamma _{Q,{\rm{ }}i}}{\rm{ }}{\psi _{0,{\rm{ }}i}}{\rm{ }}{Q_{k,{\rm{ }}i}}} }^{{\rm{\color{Red}{Other Variable Actions}}}}

This might initially appear to be quite a minor thing, but I've found that colour coding my notes like this really helps the students follow the equations when I'm talking them through various parts of the equations and so I was keen to keep the high quality formatting on my blog.  One thing that I have noticed however though is that the equations appear much much sharper on mobile devices and Apple machines, whereas on windows machines they appear slightly pixelated.

As to the second advantage this is that I can now embed Wolfram Mathematica CDF files into my blog directly, which will help me share some of my examples with anyone interested in my research.  I'll write another blog post on this over the next few days...