Mechanical Engineer’s Guide to Coding

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 me?)

STOP!

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?

Screen Shot 2016-05-17 at 10.01.58 PM

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.

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. 

latex-commands-table

[Source: Plotly Tutorial]

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

Sign up at https://www.sharelatex.com with your Chalmers student email address and get “Premium” for free. The beginner tutorials are probably better than what I can explain.

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?

Screen Shot 2016-05-17 at 9.43.47 PM


 

% 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…

A1

You can make GIF in Matlab!

giphy

You can solve very complicated math equations…

Screen Shot 2016-05-17 at 10.39.20 PM

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.

Read more here: http://www.ee.columbia.edu/~marios/matlab/MatlabStyle1p5.pdf

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.

Screen Shot 2016-05-17 at 10.45.19 PM

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!

http://ethanschoonover.com/solarized

solarized-vim


%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!

https://www.codecademy.com/learn/python

Screen Shot 2016-05-17 at 10.36.46 PM

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 avatar

4 Comments

  • Akhil • 25 May 2017 at 6.45 pm Reply

    Hey Gimmy!
    So I spent three months learning Python. But now I’m having a hard time figuring out what to exactly do with it. Being a Mechanical engineering student, do you have any ideas on what project I can do with Python?
    Thanks.

    • Gimmy • 29 May 2017 at 10.12 am Reply

      Good on you!

      Start with some basic assignments. Maybe something you have calculated by a TI84, now it is time to upgrade. If you graphed with Excel spreadsheet, try it with code. 🙂

      /Gimmy

  • Suthesh Kumar Balbir Singh • 25 May 2016 at 8.14 am Reply

    Hey Gimmy! It’s always interesting to see Mechanical students doing programming and stuffs (and at the same time, laughing at them too lol. E&E major during Bachelor’s here).

    MatLab, given time is actually very interesting and almost all Electronics major uses them (which reminds me to brush up mine too). Given all that 3 above, which one are you more inclined to using?

    Also, how easy is Phython? A couple friends of mine told me to give it a go and it does looks interesting but after facing (and getting self tortured lol) with some programming subjects, I tole myself not to take anything new unless its going to do you good for the long run.

    • Gimmy • 25 May 2016 at 9.40 am Reply

      Hi Suthesh,

      I am a big fan of Matlab, but I know many industries are shifting over from Matlab to Python. So learning Python isn’t a bad idea and looks good on resume.

      So in the long run, learn both? We are still young 🙂

      /Gimmy

Reply or comment