MATLAB: Difference between revisions

From David's Wiki
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
For optimal CPU performance, you can also use C++ with [[Eigen]].
For optimal CPU performance, you can also use C++ with [[Eigen]].


==Installation==
===Linux===
Matlab is installed at <code>/usr/local/MATLAB/<version></code>. 
E.g. <code>/usr/local/MATLAB/R2020b/bin</code>.
You can also install it to your account in <code>~/.local/</code>.
By default, matlab will not create a launcher icon. 
On Ubuntu, you can add a launcher icon by installing <code>matlab-support</code>.


==Usage==
==Usage==
Line 20: Line 28:
elapsedTime = toc(timerVal)
elapsedTime = toc(timerVal)
</syntaxhighlight>
</syntaxhighlight>
[[Category:Programming languages]]

Latest revision as of 21:11, 17 January 2023

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. You can also install it to your account in ~/.local/.

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)