MATLAB: Difference between revisions
Created page with " =Usage= ===Anonymous Functions=== [https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html Reference] <syntaxhighlight lang="matlab"> sqr = @(x) x.^2; </s..." |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Matlab is a commercial numerical computing language which costs $149.<br> | |||
Students are usually forced to use it in introductory math classes.<br> | |||
Unless required to use Matlab, I recommend using Python, Julia, or R which are all free and, in my opinion, more flexable.<br> | |||
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>. | |||
=Usage= | By default, matlab will not create a launcher icon. | ||
On Ubuntu, you can add a launcher icon by installing <code>matlab-support</code>. | |||
==Usage== | |||
===Anonymous Functions=== | ===Anonymous Functions=== | ||
[https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html Reference] | [https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html Reference] | ||
Line 7: | Line 19: | ||
sqr = @(x) x.^2; | sqr = @(x) x.^2; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Timing Code === | |||
[https://www.mathworks.com/help/matlab/matlab_prog/measure-performance-of-your-program.html Reference]<br> | |||
<code>tic</code> starts a timer. <code>toc</code> returns the time elapsed in seconds since the started timer. | |||
<syntaxhighlight lang="matlab"> | |||
timerVal = tic | |||
% The program section to time. | |||
elapsedTime = toc(timerVal) | |||
</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
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)