120 lines
4.3 KiB
Markdown
120 lines
4.3 KiB
Markdown
+++
|
|
title = "Matlab"
|
|
author = ["Thomas Dehaeze"]
|
|
draft = false
|
|
+++
|
|
|
|
Tags
|
|
: [Simulink]({{< relref "simulink" >}})
|
|
|
|
|
|
## Resources on Matlab {#resources-on-matlab}
|
|
|
|
Books:
|
|
|
|
- ([Higham 2017](#org68f863c))
|
|
- ([Attaway 2018](#org3441bfb))
|
|
- ([OverFlow 2018](#org8e0ff2b))
|
|
- ([Johnson 2010](#org019531d))
|
|
- ([Hahn and Valentine 2016](#orgbeacac3))
|
|
|
|
|
|
## 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`.
|
|
|
|
|
|
## Figures {#figures}
|
|
|
|
|
|
### Bode Plot {#bode-plot}
|
|
|
|
|
|
## Snippets {#snippets}
|
|
|
|
|
|
### Do not show legend for one plot {#do-not-show-legend-for-one-plot}
|
|
|
|
```matlab
|
|
figure;
|
|
hold on;
|
|
plot(x, y1, 'DisplayName, 'lengendname');
|
|
plot(x, y2, 'HandleVisibility', 'off');
|
|
hold off;
|
|
legend('Location', 'northeast');
|
|
```
|
|
|
|
|
|
## Linux Installation {#linux-installation}
|
|
|
|
If a single user is using the Matlab installation on the machine:
|
|
|
|
```bash
|
|
sudo chown -R $LOGNAME: /usr/local/MATLAB/R2017b
|
|
```
|
|
|
|
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.
|
|
|
|
|
|
## Used Toolboxes {#used-toolboxes}
|
|
|
|
Nice functions:
|
|
|
|
- <https://github.com/jmrplens/SetFigPaper>
|
|
- <https://github.com/altmany/export%5Ffig>
|
|
- Matlab's `exportgraphics`
|
|
- `vfit3` ([link](https://www.sintef.no/projectweb/vectorfitting/)): used to identify transfer functions
|
|
|
|
|
|
## 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 |
|
|
|
|
|
|
|
|
## Bibliography {#bibliography}
|
|
|
|
<a id="org3441bfb"></a>Attaway, Stormy. 2018. _MATLAB : a Practical Introduction to Programming and Problem Solving_. Amsterdam: Butterworth-Heinemann.
|
|
|
|
<a id="orgbeacac3"></a>Hahn, Brian, and Daniel T Valentine. 2016. _Essential MATLAB for Engineers and Scientists_. Academic Press.
|
|
|
|
<a id="org68f863c"></a>Higham, Desmond. 2017. _MATLAB Guide_. Philadelphia: Society for Industrial and Applied Mathematics.
|
|
|
|
<a id="org019531d"></a>Johnson, Richard K. 2010. _The Elements of MATLAB Style_. Cambridge University Press.
|
|
|
|
<a id="org8e0ff2b"></a>OverFlow, Stack. 2018. _MATLAB Notes for Professionals_. GoalKicker.com.
|