introduction copyright © software carpentry 2011 this work is licensed under the creative commons...
TRANSCRIPT
![Page 1: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/1.jpg)
Introduction
Copyright © Software Carpentry 2011
This work is licensed under the Creative Commons Attribution License
See http://software-carpentry.org/license.html for more information.
MATLAB Programming
![Page 2: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/2.jpg)
MATLAB Introduction
Good scientific software:
For whom is software written?
![Page 3: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/3.jpg)
MATLAB Introduction
Good scientific software:
For whom is software written?
![Page 4: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/4.jpg)
MATLAB Introduction
Good scientific software:
For whom is software written?
1) Human readable
![Page 5: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/5.jpg)
MATLAB Introduction
Good scientific software:
For whom is software written?
1) Human readable
2) Emphasizes domain and problem specific computation.
![Page 6: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/6.jpg)
MATLAB Introduction
Good scientific software:
For whom is software written?
1) Human readable
2) Emphasizes domain and problem specific computation.
3) Testable
![Page 7: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/7.jpg)
MATLAB Introduction
Good scientific software:
For whom is software written?
1) Human readable
2) Emphasizes domain and problem specific computation.
3) Testable
… and then …
4) Efficient
![Page 8: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/8.jpg)
MATLAB Introduction
Bad scientific software:
1) Emphasizes efficiency over readability
2) Emphasizes efficiency over testability
3) Reinvents the wheel
4) Couples domain specific knowledge with underlying mathematical routines.
Fast, wrong code gets you the wrong answer… faster.
![Page 9: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/9.jpg)
MATLAB Introduction
MATLAB is a …
… programming language…
… and a programming environment.
Encourages
Reuse of tested, efficient mathematical routines
High level representation of programs
Mathematical expression over details of algorithms.
![Page 10: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/10.jpg)
MATLAB Introduction
MATLAB the environment
![Page 11: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/11.jpg)
MATLAB Introduction
MATLAB the environment
![Page 12: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/12.jpg)
MATLAB Introduction
MATLAB the environment
![Page 13: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/13.jpg)
MATLAB Introduction
MATLAB the environment
![Page 14: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/14.jpg)
MATLAB Introduction
MATLAB as a programming language:
Arrays
>> nums = [1,2,3]
>> nums = nums + 4;
For loops
>> for i = nums:
>> isprime(i);
![Page 15: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/15.jpg)
MATLAB Introduction
Key idea: Data parallel programming
The programmer works at level of mathematical ideas…
… not loops and indices.
Most operators work on arrays directly.
Common theme: you probably* don’t want to use a loop
* (exceptions apply)
![Page 16: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/16.jpg)
MATLAB Introduction
Example:
>> for i = 1:length(arr)
>> arr(i) = arr(i) * 100;
>> end
Or…
>> arr = arr * 100;
![Page 17: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/17.jpg)
MATLAB Introduction
Why learn MATLAB?
Rapid prototyping
Scales well to large, production problems.
Thousands of mathematical routines
Tested
Efficient
Common language in many fields
![Page 18: Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader036.vdocuments.net/reader036/viewer/2022081519/56649db65503460f94aa7801/html5/thumbnails/18.jpg)
February 2011
created by
Richard T. Guy
Copyright © Software Carpentry 2011
This work is licensed under the Creative Commons Attribution License
See http://software-carpentry.org/license.html for more information.