MATLAB: Difference between revisions

From David's Wiki
No edit summary
No edit summary
Line 27: Line 27:
elapsedTime = toc(timerVal)
elapsedTime = toc(timerVal)
</syntaxhighlight>
</syntaxhighlight>
[[Category:Programming languages]]

Revision as of 16:43, 31 January 2022

Matlab is a commercial numerical computing language which costs $149.
Students are usually forced to use it in introductory math classes.
Unless required to use Matlab, I recommend using Python, Julia, or R which are all free and, in my opinion, more flexable.
For optimal CPU performance, you can also use C++ with Eigen.

Installation

Linux

Matlab is installed at /usr/local/MATLAB/<version>.
E.g. /usr/local/MATLAB/R2020b/bin.

By default, matlab will not create a launcher icon.
On Ubuntu, you can add a launcher icon by installing matlab-support.

Usage

Anonymous Functions

Reference

sqr = @(x) x.^2;

Timing Code

Reference
tic starts a timer. toc returns the time elapsed in seconds since the started timer.

timerVal = tic
   % The program section to time. 
elapsedTime = toc(timerVal)