Mechanical Engineer’s Guide to Coding

Gimmy

Written by Gimmy

17 May 2016

You know that old fella in the machine shop that is struggling with Windows XP (and you made fun of him?)

That guy is you in …3…..month if you have no idea about coding. (don’t believe me0 ↗️)

if     you.knowledge(coding) == 1

           break;

else

          read_on = 1;        % if you already know about coding, ignore this post!

end

I am a proud Mechanical engineer with a capital “M”,

and thus I HATED the word “coding”. Coders give me that iffy feeling… ’em hipsters sipping organic brew at some strange café tabbing away on their MacBooks.

That changed after I moved to Sweden.

Today, I am going to force feed you some basic coding. (or at least tell you which software to learn before September)

  1. LaTex
  2. Matlab
  3. Python

%1  What is LaTex?

LaTex is essentially a Word editor for Academia. Word is great for writing essays, stories, business plans, but it is just not good enough for Engineering.

Screenshot of LaTex program.

Swedes löv LaTex! (and why you should feel the löv too!)

  1. LaTex is Word. If you want to write a sentence, just write your sentence. NO DIFFERENCE.
  2. LaTex is great for writing equations, matrices, all those mathy things. Say good bye to struggle of writing 5^2 (square of 5) in Word. Just type $5^2$ and the superscript will automatically show up. $ sign means equation.
  3. LaTex documents is more organized… e.g. If you have a long Word file, it can take a while to scroll to the write section. In LaTex, you can create different several subfiles. You work on the particular one. Once finished you can compile the all subsections into one .pdf.
  4. Oh, did I forget to mention group work? ShareLaTex ↗️ allow several editor to work on the same document simultaneously! It is like Google Doc, except more serious. 
Screenshot of latex commands table.
Photo: Plotly Tutorial ↗️

At first, LaTex is intimidating… confusing… frustrating. But I PROMISE, you will löv it too!

Sign up at Sharelatex ↗️ with your Chalmers student email address and get “Premium” for free. The beginner tutorials are probably better than what I can explain.

Handwritten note.
Fatigue.

This is the remark of my last assignment during Bachelors. I was too busy (with student racecar shenanigans ↗️) to type the equations in Word, so I wrote EVERYTHING by hand… So much embarrassment. DON’T BE THIS GUY! ^

So embarrassed, I rewrote this assignment after I graduated in ShareLaTex. Doesn’t it look crisp?

Screenshot of assignment.

% 2. Matlab

During my bachelor studies I Excelled everything…. Microsoft Excel that is.

Microsoft Excel vs. Matlab for engineers is like Microsoft Paint vs. Photoshop for an advertising agency.

The things you can do in Matlab is virtually endless!

You can make pretty 2D graphs…

Screenshot of a graph.

You can make GIF in Matlab!

Photo: Giphy

You can solve very complicated math equations…

Screenshot of Matlab program.

Basic Commands to get you started:

  • clc – to clear the window
  • close all – close all figures
  • clear all – clear all variables
  • control + enter = run the command in your editor

Grammar is key!

One thing that separate future Pros from amateurs is coding grammar! Yes, coding grammar exits! There is a set of general rules on how to name your variables, name your files, etc. ↗️

Let me google that for you.

It took me a while to get used to Matlab. Now I cannot live without it. If you have problem with Matlab, chances are someone has already asked the question on google.

Screenshot of googling 'How to change plot title font size in Matlab'.

Some links to get you started!

#PROTIP! – “Solarized”

I changed my Matlab background colour to dark blue. A lot of “coders” do that. It is easier for the eyes and looks DOPE to passerby! ↗️

Screenshot of Solarized program.

%3. Python! Industry trend!

The problem with Matlab software license is that it is very very $$expensive$$. Academia usually get it for free, while companies pay big premium.

Companies like Volvo Cars have been using more and more Python instead.

Python is open-sourced, FREE!

Learn it, ↗️ use it, master it & put it on your resume!

Screenshot of Wired article showing a python calculation.
A fun example from Wired.com ↗️

Feeling bored this summer?

If you are an engineer who has never coded, start practicing! Redo your own homework assignments! Do it with Matlab and write it up in LaTex!

löv,

gimmygøteborg

17 Mai 2016 – Happy birthday, Norway!

PS! You can make pretty 3D graphs (very easily) in Matlab too!

A3Histogram.
Gimmy

Written by Gimmy

17 May 2016