Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hendri54 committed Jan 13, 2016
1 parent d892fd2 commit 656f43a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Contents:
matlab_oddities
matlab_plots
matlab_exercises
oop
project_code_organization
oop



Indices and tables
==================
Expand Down
2 changes: 1 addition & 1 deletion matlab_datatypes.mmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Matlab: Data Types
# Data Types

Matlab knows the following data types:

Expand Down
2 changes: 1 addition & 1 deletion matlab_editing.mmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Matlab: Editing and Debugging
# Editing and Debugging

## The Editor

Expand Down
4 changes: 3 additions & 1 deletion matlab_functions.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Now try `open zeros`. This opens `zeros.m`.

The Matlab [path](www.mathworks.com/help/matlab/ref/path.html) determines which m-files are visible in the global namespace (and inside all functions).

In contrast to other languages, this is an all or nothing affair: If a function is visible somewhere, it is visible everywhere. (Local functions and nested functions are the exceptions.)
In contrast to other languages, this is an all or nothing affair: If a function is visible somewhere, it is visible everywhere.

When the user issues a command, such as `m = zeros([3,4]))`, Matlab searches for a matching m-file, in this case `zeros.m` and runs it.

Expand All @@ -117,6 +117,8 @@ Therefore, every time you write new code, you need to put the directories on the

There is no way to allow one function to access some code without changing the `path` globally. This differs from other languages. It makes it hard to organize code.

There is one exception: [local functions](http://www.mathworks.com/help/matlab/matlab_prog/local-functions.html) are only visible to functions within the same m-file.

## Organizing Code ##

When you write new commands, you need to make sure Matlab can find them.
Expand Down
4 changes: 3 additions & 1 deletion matlab_intro.mmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Matlab: Introduction #
# The Basics #

## Installation and Configuration

Expand Down Expand Up @@ -133,4 +133,6 @@ To find a command for a given task, use the Matlab help system.

[List of free Matlab books](https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#matlab)

[MIT course](http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-094-introduction-to-matlab-january-iap-2010/index.htm)

------------------------------
2 changes: 1 addition & 1 deletion matlab_plots.mmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Plotting in Matlab
# Graphics

Matlab contains a large number of functions that plot data in 2D and 3D.

Expand Down
14 changes: 11 additions & 3 deletions oop.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ OOP therefore bundles data (called `properties`) and functions (called `methods`

### Example: Utility function ###

$u(c,l) = c ^ (1-\sigma) / (1-\sigma) + \phi \log(l)$
\\(u(c,l) = c ^ (1-\sigma) / (1-\sigma) + \phi \log(l)\\)

Persistent data include: parameters ($\sigma, \phi$).
Persistent data include: parameters (\\(\sigma, \phi\\)).

Methods include: compute $u_{c}$, $u(c,l)$, inverse marginal utility, indifference curves
Methods include: compute \\(u_{c}, u(c,l)\\), inverse marginal utility, indifference curves.

## Benefits ##

Expand All @@ -32,6 +32,14 @@ Since all code is in one place, it is easy to swap out.

Imagine you want to compute a model with different utility functions. With OOP, all you need to do is swap out the utility function object. Ideally, the other code remains unchanged.

## Examples From My Library ##

[CRRA utility](https://github.com/hendri54/shared/blob/master/UtilCrraLH.m)

[CES production function](https://github.com/hendri54/shared/blob/master/ces_lh.m)

[Enum](https://github.com/hendri54/shared/blob/master/EnumLH.m) data type.

## References ##

Matlab documentation on [object oriented programming](http://www.mathworks.com/help/matlab/object-oriented-programming.html).
Expand Down
2 changes: 1 addition & 1 deletion programming.mmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Programming: Notes on Writing Code
# Writing Solid Code

-----------------------------

Expand Down

0 comments on commit 656f43a

Please sign in to comment.