Difference between revisions of "MATLAB1"
Jump to navigation
Jump to search
Line 10: | Line 10: | ||
=Hints and Tips on Performance= | =Hints and Tips on Performance= | ||
+ | |||
+ | * Replace your loops with vectorised operations, e.g. | ||
+ | |||
+ | replace: | ||
+ | <pre> | ||
+ | for i = 1:length(vec) | ||
+ | vec(i) = vec(i) * 3; | ||
+ | end | ||
+ | </pre> | ||
+ | |||
+ | with: | ||
+ | <pre> | ||
+ | vec = vec*3 | ||
+ | </pre> | ||
<!-- | <!-- |
Revision as of 15:27, 30 August 2013
An Introduction MATLAB
Introduction
Rather than re-invent the wheel, we'll use some tried and tested tutorial material. The following notes from the Maths department at the University of Dundee are concise, comprehensive, but also easy to read: http://www.maths.dundee.ac.uk/ftp/na-reports/MatlabNotes.pdf
Hints and Tips on Performance
- Replace your loops with vectorised operations, e.g.
replace:
for i = 1:length(vec) vec(i) = vec(i) * 3; end
with:
vec = vec*3