2020-06-03 22:43:54 +02:00
+++
title = "Matlab"
2022-03-15 16:40:48 +01:00
author = ["Dehaeze Thomas"]
2020-06-03 22:43:54 +02:00
draft = false
+++
Tags
2022-03-15 16:40:48 +01:00
: [Simulink ]({{< relref "simulink.md" >}} )
2020-06-03 22:43:54 +02:00
## Resources on Matlab {#resources-on-matlab}
Books:
2022-03-15 16:40:48 +01:00
- (< a href = "#citeproc_bib_item_3" > Higham 2017</ a > )
- (< a href = "#citeproc_bib_item_1" > Attaway 2018</ a > )
- (< a href = "#citeproc_bib_item_5" > OverFlow 2018</ a > )
- (< a href = "#citeproc_bib_item_4" > Johnson 2010</ a > )
- (< a href = "#citeproc_bib_item_2" > Hahn and Valentine 2016</ a > )
2020-06-03 22:43:54 +02:00
## Useful Commands {#useful-commands}
| Command | Description |
|------------------------|-------------------------------------------------------------|
| `desktop` | Open the Matlab Desktop |
| `workspace` | Open the Workspace |
| `who` | List all variables in the workspace |
| `edit <filename>` | Edit the file using Matlab Desktop (usefully for debugging) |
| `help <function>` | |
| `doc <function>` | |
| `checkcode <filename>` | Check Matlab code files for possible problems |
| `preferences` | Open Matlab preferences |
## Tips {#tips}
- Folder that starts with a `+` are automatically added to the path.
It is useful to add function inside such folder.
Then the function is accessible with `folder.function` .
2020-10-19 16:00:25 +02:00
## Figures {#figures}
### Bode Plot {#bode-plot}
2020-06-03 22:43:54 +02:00
## Snippets {#snippets}
### Do not show legend for one plot {#do-not-show-legend-for-one-plot}
```matlab
2021-05-02 20:37:00 +02:00
figure;
hold on;
plot(x, y1, 'DisplayName, 'lengendname');
plot(x, y2, 'HandleVisibility', 'off');
hold off;
legend('Location', 'northeast');
2020-06-03 22:43:54 +02:00
```
2020-08-17 11:21:16 +02:00
## Linux Installation {#linux-installation}
2020-06-03 22:43:54 +02:00
2020-08-13 11:19:08 +02:00
If a single user is using the Matlab installation on the machine:
2020-06-03 22:43:54 +02:00
2020-08-13 11:19:08 +02:00
```bash
2021-05-02 20:37:00 +02:00
sudo chown -R $LOGNAME: /usr/local/MATLAB/R2017b
2020-08-13 11:19:08 +02:00
```
Then, Toolboxes can be installed by the user without any problem.
To install Toolboxes, the best is to Download the Matlab installer from mathworks and just select the wanted toolboxes.
2020-08-17 11:21:16 +02:00
## Used Toolboxes {#used-toolboxes}
2020-08-17 21:59:26 +02:00
Nice functions:
- < https: // github . com / jmrplens / SetFigPaper >
2022-03-15 16:40:48 +01:00
- < https: // github . com / altmany / export_fig >
2020-08-17 21:59:26 +02:00
- Matlab's `exportgraphics`
2020-08-17 11:21:16 +02:00
- `vfit3` ([link](https://www.sintef.no/projectweb/vectorfitting/)): used to identify transfer functions
2020-08-17 21:59:26 +02:00
## Debug Scripts {#debug-scripts}
< https: / / fr . mathworks . com / help / matlab / debugging-code . html >
< https: / / stackoverflow . com / questions / 22853116 / how-to-debug-matlab-code-without-gui >
| Command | Effect |
|------------|--------------------------------------------------------------|
| `dbclear` | Remove breakpoints |
| `dbcont` | Resume execution |
| `dbdown` | Reverse dbup workspace shift |
| `dbquit` | Quit debug mode |
| `dbstack` | Function call stack |
| `dbstatus` | List all breakpoints |
| `dbstep` | Execute next executable line from current breakpoint |
| `dbstop` | Set breakpoints for debugging |
| `dbtype` | Display file with line numbers |
| `dbup` | Shift current workspace to workspace of caller in debug mode |
| `keyboard` | Give control to keyboard |
| `echo` | Display statements during function execution |
2020-08-13 11:19:08 +02:00
## Bibliography {#bibliography}
2022-03-15 16:40:48 +01:00
< style > . csl-entry { text-indent : -1.5 em ; margin-left : 1.5 em ; } < / style > < div class = "csl-bib-body" >
< div class = "csl-entry" > < a id = "citeproc_bib_item_1" > < / a > Attaway, Stormy. 2018. < i > Matlab : a Practical Introduction to Programming and Problem Solving< / i > . Amsterdam: Butterworth-Heinemann.< / div >
< div class = "csl-entry" > < a id = "citeproc_bib_item_2" > < / a > Hahn, Brian, and Daniel T Valentine. 2016. < i > Essential Matlab for Engineers and Scientists< / i > . Academic Press.< / div >
< div class = "csl-entry" > < a id = "citeproc_bib_item_3" > < / a > Higham, Desmond. 2017. < i > Matlab Guide< / i > . Philadelphia: Society for Industrial and Applied Mathematics.< / div >
< div class = "csl-entry" > < a id = "citeproc_bib_item_4" > < / a > Johnson, Richard K. 2010. < i > The Elements of Matlab Style< / i > . Cambridge University Press.< / div >
< div class = "csl-entry" > < a id = "citeproc_bib_item_5" > < / a > OverFlow, Stack. 2018. < i > Matlab Notes for Professionals< / i > . GoalKicker.com.< / div >
< / div >