-
Notifications
You must be signed in to change notification settings - Fork 2
/
matlab_data_types.html
297 lines (287 loc) · 9.85 KB
/
matlab_data_types.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
<!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 Data</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-elements-and-syntax">Working with Data in MATLAB</h1>
<h2 id="1-data-types">1. Data Types</h2>
<p>Data types (also referred to as classes) define the kind of data a variable can hold and the operations that can be performed on it. </p>
<ul>
<li><p><strong>Numeric Types</strong></p>
<ul>
<li><strong>double</strong>: This is the default numeric data type in MATLAB. Suitable for general-purpose numerical computations where precision and range are important.</li>
<li><strong>Integer Types</strong>: Whole numbers only, which require less memory but have less precision and limitations on certain mathematical operations compared to double.</li>
</ul>
</li>
<li><p><strong>Character and String Types</strong></p>
<ul>
<li><strong>char</strong>: Character arrays for storing text created using single quotes.</li>
<li><strong>string</strong>: String arrays, which are more flexible than character arrays and can be created using double quotes.</li>
</ul>
</li>
<li><p><strong>Logical Type</strong></p>
<ul>
<li><strong>logical</strong>: Represents true or false values.</li>
</ul>
</li>
</ul>
<h3 id="4b-sets-and-operators">4b. Sets and Operators</h3>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Arithmetic</strong></td>
</tr>
<tr>
<td><code>+</code></td>
<td>Addition</td>
<td><code>a + b</code></td>
</tr>
<tr>
<td><code>-</code></td>
<td>Subtraction</td>
<td><code>a - b</code></td>
</tr>
<tr>
<td><code>*</code></td>
<td>Matrix multiplication</td>
<td><code>a * b</code></td>
</tr>
<tr>
<td><code>.*</code></td>
<td>Element-wise multiplication</td>
<td><code>a .* b</code></td>
</tr>
<tr>
<td><code>/</code></td>
<td>Matrix right division</td>
<td><code>a / b</code></td>
</tr>
<tr>
<td><code>./</code></td>
<td>Element-wise right division</td>
<td><code>a ./ b</code></td>
</tr>
<tr>
<td><code>\</code></td>
<td>Matrix left division</td>
<td><code>a \ b</code></td>
</tr>
<tr>
<td><code>.\</code></td>
<td>Element-wise left division</td>
<td><code>a .\ b</code></td>
</tr>
<tr>
<td><code>^</code></td>
<td>Matrix power</td>
<td><code>a ^ b</code></td>
</tr>
<tr>
<td><code>.^</code></td>
<td>Element-wise power</td>
<td><code>a .^ b</code></td>
</tr>
<tr>
<td><code>.'</code></td>
<td>Transpose</td>
<td><code>a.'</code></td>
</tr>
<tr>
<td><strong>Relational</strong></td>
</tr>
<tr>
<td><code>==</code></td>
<td>Equal to</td>
<td><code>a == b</code></td>
</tr>
<tr>
<td><code>~=</code></td>
<td>Not equal to</td>
<td><code>a ~= b</code></td>
</tr>
<tr>
<td><code>></code></td>
<td>Greater than</td>
<td><code>a > b</code></td>
</tr>
<tr>
<td><code><</code></td>
<td>Less than</td>
<td><code>a < b</code></td>
</tr>
<tr>
<td><code>>=</code></td>
<td>Greater than or equal to</td>
<td><code>a >= b</code></td>
</tr>
<tr>
<td><code><=</code></td>
<td>Less than or equal to</td>
<td><code>a <= b</code></td>
</tr>
<tr>
<td><strong>Logical</strong></td>
</tr>
<tr>
<td><code>&</code></td>
<td>Logical AND</td>
<td><code>a & b</code></td>
</tr>
<tr>
<td>`\</td>
<td>`</td>
<td>Logical OR</td>
<td>`a</td>
<td>b`</td>
</tr>
<tr>
<td><code>~</code></td>
<td>Logical NOT</td>
<td><code>~a</code></td>
</tr>
<tr>
<td><code>xor</code></td>
<td>Logical EXCLUSIVE OR</td>
<td><code>xor(a, b)</code></td>
</tr>
<tr>
<td><strong>Sets</strong></td>
</tr>
<tr>
<td><code>union</code></td>
<td>Union of two sets</td>
<td><code>union(a, b)</code></td>
</tr>
<tr>
<td><code>intersect</code></td>
<td>Intersection of two sets</td>
<td><code>intersect(a, b)</code></td>
</tr>
<tr>
<td><code>setdiff</code></td>
<td>Difference of two sets</td>
<td><code>setdiff(a, b)</code></td>
</tr>
<tr>
<td><code>setxor</code></td>
<td>Symmetric difference of two sets</td>
<td><code>setxor(a, b)</code></td>
</tr>
<tr>
<td><code>ismember</code></td>
<td>Determine if elements are members of a set</td>
<td><code>ismember(a, b)</code></td>
</tr>
<tr>
<td><code>unique</code></td>
<td>Unique elements in an array</td>
<td><code>unique(a)</code></td>
</tr>
</tbody>
</table>
<h2 id="3-suggested-tutorials">3. Suggested Tutorials</h2>
<p><a href="https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe#module=5">Tutorial: Mathematical and Statistical Operations with Arrays</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe#module=7">Tutorial: Conditional Data Selection</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe#module=9">Tutorial: Tables of Data</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe#module=10">Tutorial: Organizing Tabular Data</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/a-tour-of-matlab-data-types/otmlmdt">Course: A tour of MATLAB Data Types</a> </p>
<p><a href="https://matlabacademy.mathworks.com/details/calculations-with-vectors-and-matrices/otmlcvm">Course: Calculations with Vectors and Matrices</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/tables/otmltab">Course: Tables</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/find-and-extract-subsets-of-data/otmlesd">Course: Find and Extract Subsets of Data</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/clean-and-prepare-data-for-analysis/otmlpda">Course: Clean and Prepare Data for Analyses</a></p>
<p><a href="https://matlabacademy.mathworks.com/details/calculations-on-grouped-data/otmlcgd">Course: Calculations on Grouped Data</a></p>
<h2 id="4-supplemental-materials">4. Supplemental Materials</h2>
<p><a href="https://www.mathworks.com/videos/introducing-matlab-fundamental-classes-data-types-101503.html">Video: Introducing MATLAB Fundamental Classes</a></p>
<p><a href="https://www.tutorialspoint.com/matlab/matlab_data_types.htm">Live Demo: Data Types</a></p>
<p><a href="https://www.tutorialspoint.com/matlab/matlab_numbers.htm">Live Demo: Numbers</a></p>
<p><a href="https://www.tutorialspoint.com/matlab/matlab_strings.htm">Live Demo: Strings</a></p>
<p><a href="https://www.mathworks.com/help/matlab/matlab_prog/fundamental-matlab-classes.html">Documentation: Fundamental MATLAB Classes</a></p>
<p><a href="https://www.mathworks.com/help/matlab/data-types.html">Documentation: Data Types</a></p>
<p><a href="https://www.mathworks.com/help/matlab/operators-and-elementary-operations.html">Documentation: Operators and Elementary Operations</a></p>
<p><a href="https://andysbrainbook.readthedocs.io/en/latest/Matlab/Matlab_02_VariablesStructures.html">Andy's Brain Book: Variables and Structures</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_files.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>