-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmatlab_basics.html
388 lines (378 loc) · 15 KB
/
matlab_basics.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<!DOCTYPE HTML>
<!--
Phantom by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>MATLAB Workspace</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Header -->
<header id="header">
<div class="inner">
<!-- Logo -->
<a href="index.html" class="logo">
<span class="symbol"><img src="images/NeuroNestLogo.png" alt="NeuroNest Logo" /></span><span class="title">NeuroNest</span>
</a>
<!-- Nav -->
<nav>
<ul>
<li><a href="#menu">Menu</a></li>
</ul>
</nav>
</div>
</header>
<!-- Menu -->
<nav id="menu">
<h2>Menu</h2>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="resource_menu.html">Resources</a></li>
<li><a href="https://sopkoc.wixsite.com/neuronest/forum">Ask a Question</a></li>
<li><a href="https://sopkoc.wixsite.com/neuronest/about">About NeuroNest</a></li>
<li><a href="https://sopkoc.wixsite.com/neuronest/contact">Contact</a></li>
</ul>
</nav>
<!-- Main -->
<div id="main">
<div class="inner">
<h1 id="MATLAB Workspace Basics">MATLAB Workspace Basics</h1>
<h2>1. How to Access MATLAB</h2>
<p>You can access MATLAB directly from your local computer (suggested) or from a standard web browser with MATLAB Online. To access MATLAB you must have a MathWorks Account and a MATLAB license (usually obtained through your university).</p>
<p><a href="https://www.mathworks.com/help/install/ug/install-products-with-internet-connection.html">Instructions on installing MATLAB</a></p>
<p><a href="https://www.mathworks.com/help/matlab-online-server/ug/matlab-online.html">Instructions on accessing MATLAB Online</a></p>
<h2 id="2-matlab-interface-">2. MATLAB Interface:</h2>
<p>When you first open MATLAB, you will notice that it has several windows and a ribbon of buttons at the top. The window on the left is the <strong>Current Folder</strong>, the central window is the <strong>Command Window</strong>, and the upper-right window is the <strong>Workspace</strong>.</p>
<ul>
<li><p><strong>Current Folder:</strong> Shows a list of all the folders located within the folder you are currently in. (This is essentially your window.)</p>
</li>
<li><p><strong>Command Window:</strong> The main area where you can type commands directly and see their output.</p>
</li>
<li><p><strong>Editor Window:</strong> Where you writing, running, and debugging MATLAB code</p>
</li>
<li><p><strong>Workspace Window:</strong> Displays variables created during the session, providing an overview of the data you are working with.</p>
</li>
</ul>
<img width="600" alt="image" src="https://github.com/user-attachments/assets/27b88c90-33be-4848-a7ee-04495f7446e0"></p>
<h2 id="3-customization-and-setting-preferences">3. Customization and Setting Preferences</h2>
<p>MATLAB offers flexible customization options to optimize your workflow. Some ways to tailor the interface include...</p>
<ul>
<li><strong>Resize and Reposition Windows:</strong> Adjust the size and position of MATLAB windows by clicking and dragging the window dividers or title bars to suit your preferences.</li>
<li><strong>Save Frequently Used Commands :</strong> The Favorites menu allows you to bookmark commonly used commands. Add a command by selecting 'New Favorite,' entering the command, and giving it a descriptive name. For quicker access, add these favorites to the Quick Access toolbar and execute them with a single click.</li>
<li><strong>Display Variable Details:</strong> To gain more insights into the variables you're working with, such as their types or memory usage, right-click the header bar in the Workspace window and choose the properties you wish to display.</li>
</ul>
<p>For more advanced customizations, navigate to <strong>Preferences</strong> under the Home tab.
<img width="600" alt="image" src="https://github.com/user-attachments/assets/cdc7c230-c22d-41e6-917a-ec8468bc5eeb"></p>
<h2 id="4-search-path-and-directories-">4. Search Path and Directories:</h2>
<p>A <strong>directory</strong> is a location in the file system that can contain files and other directories (subdirectories). It's essentially a folder where files and other folders are organized.</p>
<p>MATLAB organizes folders and files using a directory tree, starting with the root directory (<code>/</code>).</p>
<p>A <strong>path</strong> is a string that specifies the location of a file or directory in the file system. It can be an absolute path (starting from the root of the file system) or a relative path (relative to the current directory)</p>
<ul>
<li><strong>Absolute Path:</strong> Specifies the entire path from the root directory. E.g., <code>/home/user/Documents/file.txt</code></li>
<li><strong>Relative Path:</strong> Specifies the path relative to the current directory. E.g., <code>Documents/file.txt</code> if the current directory is /home/user.</li>
</ul>
<p>The <strong>search path</strong> is a subset of all the folders in the file system that MATLAB uses to locate files efficiently. The order of folders on the search path is significant: MATLAB uses the file in the folder nearest to the top when multiple files with the same name exist. For more information, see <a href="https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html">What Is the MATLAB Search Path?</a>.</p>
<h2 id="5-command-cheat-sheet">5. Command Cheat Sheet</h2>
<table>
<thead>
<tr>
<th>Commands</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Directories and Paths</strong></td>
</tr>
<tr>
<td><code>pwd</code></td>
<td>Prints the current working directory path.</td>
</tr>
<tr>
<td><code>cd 'folder'</code></td>
<td>Changes the current working directory to 'folder'.</td>
</tr>
<tr>
<td><code>cd ~</code></td>
<td>Changes the current directory to the user's home directory.</td>
</tr>
<tr>
<td><code>cd .</code></td>
<td>Refers to the current directory.</td>
</tr>
<tr>
<td><code>cd ..</code></td>
<td>Moves up one level in the directory tree.</td>
</tr>
<tr>
<td><code>ls</code></td>
<td>Lists all files and directories in the current directory.</td>
</tr>
<tr>
<td><code>dir</code></td>
<td>Lists directory contents, similar to <code>ls</code>.</td>
</tr>
<tr>
<td><code>what</code></td>
<td>Lists all MATLAB specific files in the current directory.</td>
</tr>
<tr>
<td><code>mkdir 'dirname'</code></td>
<td>Creates a new directory named 'dirname'.</td>
</tr>
<tr>
<td><code>rmdir 'dirname'</code></td>
<td>Removes the directory named 'dirname', if it is empty.</td>
</tr>
<tr>
<td><code>path</code></td>
<td>Displays the current MATLAB search path.</td>
</tr>
<tr>
<td><code>addpath 'folder'</code></td>
<td>Adds the specified folder to the MATLAB search path.</td>
</tr>
<tr>
<td><code>rmpath 'folder'</code></td>
<td>Removes the specified folder from the MATLAB search path.</td>
</tr>
<tr>
<td><code>savepath</code></td>
<td>Saves the current MATLAB search path for future sessions.</td>
</tr>
<tr>
<td><strong>Files</strong></td>
</tr>
<tr>
<td><code>exist 'name'</code></td>
<td>Checks if a variable, file, or folder 'name' exists.</td>
</tr>
<tr>
<td><code>load 'filename'</code></td>
<td>Loads variables from a file into the workspace.</td>
</tr>
<tr>
<td><code>save 'filename'</code></td>
<td>Saves workspace variables to a file.</td>
</tr>
<tr>
<td><code>type 'filename'</code></td>
<td>Displays the contents of the specified file.</td>
</tr>
<tr>
<td><code>which 'filename'</code></td>
<td>Returns the full path if the file is on the search path.</td>
</tr>
<tr>
<td><code>edit 'filename'</code></td>
<td>Opens the specified file in MATLAB's editor.</td>
</tr>
<tr>
<td><strong>Command Help</strong></td>
</tr>
<tr>
<td><code>doc command</code></td>
<td>Opens the documentation for 'command'.</td>
</tr>
<tr>
<td><code>help command</code></td>
<td>Displays help text for 'command' in the Command Window.</td>
</tr>
<tr>
<td><code>clc</code></td>
<td>Clears all input and output from the Command Window, keeping history.</td>
</tr>
<tr>
<td><code>quit</code> or <code>exit</code></td>
<td>Closes MATLAB.</td>
</tr>
<tr>
<td><strong>Managing Workspace</strong></td>
</tr>
<tr>
<td><code>clc</code></td>
<td>Clears all input and output from the Command Window, keeping history.</td>
</tr>
<tr>
<td><code>clear</code></td>
<td>Clears all input and output from the Command Window, keeping history.</td>
</tr>
<tr>
<td><code>quit</code> or <code>exit</code></td>
<td>Closes MATLAB.</td>
</tr>
</tbody>
</table>
<h2 id="6-keyboard-shortcuts-for-matlab-command-window">6. Keyboard Shortcuts for MATLAB Command Window</h2>
<p>Keyboard shortcuts in MATLAB's Command Window mirror the functionality often used in terminal environments. </p>
<p>Note - These shortcuts will only work if you have MATLAB installed in your system. MATLAB Online provides access to MATLAB from a standard web browser. Because MATLAB Online runs in a browser, navigation using the keyboard is slightly different.</p>
<h4 id="for-windows-users">For Windows Users</h4>
<table>
<thead>
<tr>
<th>Shortcut</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Up Arrow</code></td>
<td>Scrolls through the history to recall previous commands, useful for repetition or modification.</td>
</tr>
<tr>
<td><code>Down Arrow</code></td>
<td>Scrolls forward in the command history after using the Up Arrow.</td>
</tr>
<tr>
<td><code>Home</code> or <code>Ctrl + A</code></td>
<td>Jumps to the beginning of the current line.</td>
</tr>
<tr>
<td><code>End</code> or <code>Ctrl + E</code></td>
<td>Jumps to the end of the current line.</td>
</tr>
<tr>
<td><code>Tab</code></td>
<td>Auto-completes commands and variable names based on partially typed text.</td>
</tr>
<tr>
<td><code>Backspace</code></td>
<td>Deletes the character to the left of the cursor.</td>
</tr>
<tr>
<td><code>Delete</code></td>
<td>Deletes the character right at the cursor position.</td>
</tr>
<tr>
<td><code>Enter</code></td>
<td>Executes the command currently typed in the Command Window.</td>
</tr>
<tr>
<td><code>Shift + Enter</code></td>
<td>Continues command entry onto the next line for multi-line commands.</td>
</tr>
<tr>
<td><code>Ctrl + L</code></td>
<td>Clears the screen, keeping the history intact.</td>
</tr>
<tr>
<td><code>Esc</code></td>
<td>Cancels the current command line input without executing it.</td>
</tr>
<tr>
<td><code>Ctrl + C</code></td>
<td>Interrupts the execution of the current command or script.</td>
</tr>
</tbody>
</table>
<h4 id="for-mac-users">For Mac Users</h4>
<table>
<thead>
<tr>
<th>Shortcut</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Up Arrow</code></td>
<td>Scrolls through the history to recall previous commands.</td>
</tr>
<tr>
<td><code>Down Arrow</code></td>
<td>Scrolls forward in the command history after using the Up Arrow.</td>
</tr>
<tr>
<td><code>Cmd + Left Arrow</code> or <code>Ctrl + A</code></td>
<td>Mimics the Home key, jumping to the beginning of the line.</td>
</tr>
<tr>
<td><code>Cmd + Right Arrow</code> or <code>Ctrl + E</code></td>
<td>Mimics the End key, jumping to the end of the line.</td>
</tr>
<tr>
<td><code>Tab</code></td>
<td>Auto-completes commands and variable names based on partially typed text.</td>
</tr>
<tr>
<td><code>Delete</code></td>
<td>Deletes the character to the left of the cursor. (Mac keyboards typically do not have a separate Backspace key.)</td>
</tr>
<tr>
<td><code>Fn + Delete</code></td>
<td>Deletes the character right at the cursor position.</td>
</tr>
<tr>
<td><code>Return</code></td>
<td>Executes the command currently typed in the Command Window.</td>
</tr>
<tr>
<td><code>Shift + Return</code></td>
<td>Continues command entry onto the next line for multi-line commands.</td>
</tr>
<tr>
<td><code>Cmd + K</code></td>
<td>Clears the screen, keeping the history intact.</td>
</tr>
<tr>
<td><code>Esc</code></td>
<td>Cancels the current command line input without executing it.</td>
</tr>
<tr>
<td><code>Ctrl + C</code></td>
<td>Interrupts the execution of the current command or script.</td>
</tr>
</tbody>
</table>
<h2 id="7-suggested-tutorials">7. Suggested Tutorials</h2>
<p><a href="https://matlabacademy.mathworks.com/details/matlab-desktop-tools-and-troubleshooting-scripts/otmldts#module=2">Lesson: The MATLAB Desktop</a></p>
<h2 id="8-supplemental-resources">8. Supplemental Resources</h2>
<p><a href="https://www.mathworks.com/help/matlab/matlab_env/command-window-preferences.html">Documentation: Set Command Window Preferences</a></p>
<p><a href="https://www.youtube.com/watch?v=LEaT9Jp7MdQ&list=PLn0OLiymPak2HkkG-NToKdP7ye7NlpC8D&index=3">Video: Using and Customizing the MATLAB Environment</a></p>
<p><a href="https://www.mathworks.com/help/matlab/search-path.html?s_tid=CRUX_lftnav">Documentation: Search Path</a></p>
</div>
</div>
<!-- Place the bird image and text anywhere on the page -->
<div style="text-align: right; padding-right: 40px;">
<a href="matlab_elements.html">
<img src="images/small_bird_arrow.png" alt="Next Page" style="width: 100px; height: 100px;">
<div style="font-size: 18px; margin-top: 10px;">Next Page</div>
</a>
</div>
<!-- Footer -->
<footer id="footer">
<div class="inner">
<section>
<h2>Funding</h2>
<p> We would like to express our heartfelt gratitude to <strong>Neurohackademy</strong> at the <strong>University of Washington eScience Institute</strong> for providing invaluable training and support. This experience has significantly enriched our understanding of neuroimaging and data science. We also acknowledge the support of the National Institute of Mental Health (NIMH) grant number <strong>5R25MH112480-08</strong>, which made this opportunity possible.</p>
</section>
<section>
<h2>Follow</h2>
<ul class="icons">
<li><a href="https://x.com/Neuro_Nest" class="icon brands style2 fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="https://github.com/NeuroHackademy2024/NeuroNest" class="icon brands style2 fa-github"><span class="label">GitHub</span></a></li>
<li><a href="mailto:[email protected]" class="icon solid style2 fa-envelope"><span class="label">Email</span></a></li>
</ul>
</section>
<ul class="copyright">
<li>© Untitled. All rights reserved</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
</ul>
</div>
</footer>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>