Difference between revisions of "Getting started with MATLAB or Python"
Line 63: | Line 63: | ||
[[Image:MATLAB_start.PNG|center|400px]] | [[Image:MATLAB_start.PNG|center|400px]] | ||
*Do not worry if MATLAB does not open exactly like this. You can easily modify what windows are visible through the '''Desktop''' drop down menu. You can select the windows you want either by toggling them individually (<span style="color:red">Region A</span>) or by selecting a template (<span style="color:blue">Region B</span>). Selecting the ''default'' template should give you the window layout you saw above. | *Do not worry if MATLAB does not open exactly like this. You can easily modify what windows are visible through the '''Desktop''' drop down menu. You can select the windows you want either by toggling them individually (<span style="color:red">Region A</span>) or by selecting a template (<span style="color:blue">Region B</span>). Selecting the ''default'' template should give you the window layout you saw above. | ||
Line 75: | Line 74: | ||
;1. Command Window | ;1. Command Window | ||
:The command window (or "command line") provides your main means of interacting with the MATLAB software. The command line allows you to enter simple codes that are | :The command window (or "command line") provides your main means of interacting with the MATLAB software. The command line allows you to enter simple codes that are processed immediately. All program outputs also appear in the command window. While it is technically possible to write an entire program at the command line, this is not recommended. For true programs, scripts and functions will be used. | ||
;2. Current Directory | ;2. Current Directory | ||
Line 100: | Line 99: | ||
# Select the <tt>--pylab</tt> option | # Select the <tt>--pylab</tt> option | ||
# Then launch the Spyder environment. | # Then launch the Spyder environment. | ||
* Python(x,y) has a layout similar to that shown below [[Image:Layout-pythonxy-low.jpg|borderless|center|500px]] | |||
;1. Command Window | |||
:The command window is where you interact with Python. Commands entered here are processed immediately. While it is technically possible to write an entire program at the command line, this is not recommended. For true programs, you should write a script in region 5 of the software. | |||
;2. Current Directory | |||
:The "current directory" panel lists all of the files that are located in the directory Python is currently accessing. This directory may be changed by navigating to a new directory and clicking on its name. | |||
;3. Command History | |||
:The command history records all commands entered in the command window (for possible future reference). | |||
;4. Workspace | |||
:The workspace lists all variables (e.g. vectors and matrices) currently available to you. The workspace also provides the size and "type" of variable. You can double click on a variable and change its value: e.g. edit a specific entry in a vector, in a spreadsheet-like interface. | |||
;5. Editor Window | |||
:The editor window is where you write scripts and function files. After saving the file to disk, you can run it by pressing <tt>F9</tt> (or click on <tt>Source</tt> in the top menu and select <tt>Run in interactive console</tt>) | |||
You can have one or multiple files open at any time. | |||
;6. Plot Window | |||
:Python plots are opened in new separate windows, but can be "docked" (placed) anywhere inside the main Python(x,y) window. | |||
|} | |} |
Revision as of 18:00, 12 September 2010
Introduction
MATLAB | Python |
---|---|
MATLAB (MATrix LABoratory) is a high level computer language/ interactive software package developed and distributed by MathWorks™. Matlab was first developed in the 1970s by Cleve Molar. Cleve was later joined by John N. Little and Steve Bangert and the three went on to found MathWorks™. MATLAB excels at performing matrix operations and can handle large data sets (stored as matrices) very easily. MATLAB was originally designed as a user friendly interface for LINPACK and EISPACK and so was intended for linear algebra application. Since then MATLAB has greatly expanded it's core abilities to encompass a large array of graphic and numeric applications. These core abilities may in turn be expanded further through the addition of specialized "tool boxes". |
From Wikipedia: Python is a high-level programming language whose design philosophy emphasizes code readability. Python aims to combine "remarkable power with very clear syntax", and its standard library of built-in functions is large and comprehensive. We will use the NumPy and SciPy modules (the equivalent of a MATLAB toolbox), to provide scientific computing capabilities to Python. These modules, like MATLAB, allow you to handle large data arrays with little effort. They provide all the tools we require for this course. We will also use the matplotlib module, which provides Python with plotting capabilities similar to MATLAB. |
Access / Installation
MATLAB | Python |
---|---|
MATLAB is installed on all computers in the John Hodgins Engineering Student Technology Centre (JHE 233A / 234) as well as the Burke Science Building Labs (BSB 241 / 242 / 244 / 249). The most up to date release of MATLAB is version R2010b. While there are some backward compatibility issues when it comes to older versions of MATLAB, for the level of code that will be encountered in this class students should not encounter issues with portability of code. A MATLAB/SIMULINK student package (version R2010A, good for Windows, Mac, and Linux) is available at the University Book Store for $112.95 (for those students who would like a copy of MATLAB on their laptop or home PC). The student versions comes with the following features:
I personally have a student copy on my home PC. It's a good buy if you have the extra cash. |
Python is freely available. The latest stable version that we recommend for the course is version 2.6, because it is compatible with the external libraries that we will use. Installation instructions for Python are available on this website. |
Getting started
These descriptions are specific to Windows-users. Mac and Linux users will have a similar display.
MATLAB | Python |
---|---|
|
When starting Python(x,y) you will be presented with the following window. Spyder (Scientific PYthon Development EnviRonment) is the name of the development environment we will be using.
You can have one or multiple files open at any time.
|
Introduction to the Command Line
|
|
Scripts and Functions
|
|
Code Structures
|
|
Plotting Data
|
|
Additional Resources
|
|