-
Notifications
You must be signed in to change notification settings - Fork 2
/
matlab_files.html
179 lines (169 loc) · 7.71 KB
/
matlab_files.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
<!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 Files</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>Handling Files in MATLAB</h1>
<h2 id="1-matlab-file-types-">1. MATLAB File Types:</h2>
<ul>
<li><p><strong>.m files</strong>: MATLAB script and function files.</p>
</li>
<li><p><strong>.mlx files</strong>: MATLAB live script files that combine code execution with narrative, formatted text, equations, images, and hyperlinks in a single, interactive document. Ideal for instructional purposes, interactive applications, and sharing results.</p>
</li>
<li><p><strong>.mat files</strong>: Binary files that store workspace variables. Useful for saving your session data and transferring variables between sessions without losing integrity.</p>
</li>
<li><p><strong>.fig files</strong>: Figure files that save MATLAB graphical outputs. They enable you to reopen and modify figures later, preserving the graphical data and properties exactly as saved.</p>
</li>
</ul>
<h2 id="2-importing-and-exporting-files">2. Importing and Exporting Files</h2>
<p>MATLAB supports importing and exporting various data formats such as TXT, CSV, XLS, XLSX, JPG, PNG, etc. You can find additional documentation including functions and examples <a href="https://www.mathworks.com/help/matlab/import_export/supported-file-formats-for-import-and-export.html">here</a>.</p>
<h2 id="3-commands-for-handling-files">3. Commands for Handling Files</h2>
<table>
<thead>
<tr>
<th>Command</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>save 'filename'</code></td>
<td>Saves workspace variables to a file.</td>
</tr>
<tr>
<td><code>load 'filename'</code></td>
<td>Loads variables from a file into the workspace.</td>
</tr>
<tr>
<td><code>readtable('filename')</code></td>
<td>Imports data from a file into a table, supporting CSV, TXT, and Excel formats.</td>
</tr>
<tr>
<td><code>readmatrix('filename')</code></td>
<td>Reads numerical data from a file into a matrix, ideal for straightforward data formats.</td>
</tr>
<tr>
<td><code>xlsread('filename')</code></td>
<td>Imports data from Excel files, useful for datasets in spreadsheets.</td>
</tr>
<tr>
<td><code>csvread('filename')</code></td>
<td>Reads numerical data from CSV files directly into an array.</td>
</tr>
<tr>
<td><code>fopen('filename')</code></td>
<td>Opens a file for reading or writing, necessary for file manipulation.</td>
</tr>
<tr>
<td><code>fwrite(fid, data)</code></td>
<td>Writes binary data to the file specified by <code>fid</code>.</td>
</tr>
<tr>
<td><code>fprintf(fid, format, data)</code></td>
<td>Writes formatted data to the file, allowing for customizable text outputs.</td>
</tr>
<tr>
<td><code>fclose(fid)</code></td>
<td>Closes an open file to free up resources.</td>
</tr>
<tr>
<td><code>importdata('filename')</code></td>
<td>Loads mixed data from files, handling various formats automatically.</td>
</tr>
<tr>
<td><code>exportdata('data', 'filename')</code></td>
<td>Exports data to a file in chosen formats, useful for sharing or external use.</td>
</tr>
</tbody>
</table>
<h2 id="4-suggested-tutorials">4. Suggested Tutorials</h2>
<p><a href="https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe#module=2">Lesson: Gettting Data Into MATLAB</a></p>
<p><a href="https://www.tutorialspoint.com/matlab_m_files/index.htm">Tutorial: M Files</a></p>
<h2 id="5-supplemental-materials">5. Supplemental Materials</h2>
<p><a href="https://www.tutorialspoint.com/matlab/matlab_data_import.htm">Live Demo: Data Import</a></p>
<p>[Live Demo: Data Output] (<a href="https://www.tutorialspoint.com/matlab/matlab_data_import.htm">https://www.tutorialspoint.com/matlab/matlab_data_import.htm</a>)</p>
<p><a href="https://tutorialspoint.com/matlab_m_files/matlab_m_files_quick_guide.htm">Quick Guide: M Files</a></p>
<p><a href="https://www.mathworks.com/help/matlab/import_export/supported-file-formats-for-import-and-export.html">Documentation: Supported File Formats</a></p>
<p><a href="https://www.mathworks.com/help/matlab/spreadsheets.html?">Documentation: Spreadsheets</a></p>
<p><a href="https://www.mathworks.com/help/matlab/data-import-and-export.html">Documentation: Data Import and Export</a></p>
<p><a href="https://www.mathworks.com/help/matlab/file-operations.html">Documentation: File Operations</a></p>
<p><a href="https://www.mathworks.com/help/matlab/cloud-file-storage.html">Documentation: Cloud File Storage</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_functions.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>