You can use the load function to import mat files. But today I got a data file with the suffix '. data '. How should I read it?
I only use the "Import Data" button in the workspace area of the MATLAB interface to manually import the file. Well, it turned out to be a success. By the way, this "import data" button is very powerful and can be imported into Excel files.
But suppose how to import such non-mat files in the script?
At this time, the "importdata" function is coming!
---------------------------------------------------------------------
Importdata
Load data from File
Syntax
Importdata (filename)
A = importdata (filename)
A = importdata (filename, delimiter)
A = importdata (filename, delimiter, nheaderlines)
[A, delimiter] = importdata (...)
[A, delimiter, nheaderlines] = importdata (...)
[...] = Importdata ('-pastespecial ',...)
Description
Importdata (filename) loads data from filename into the workspace.
A = importdata (filename) loads data into.
A = importdata (filename, delimiter) Interprets delimiter as the column Separator in ASCII file filename.
A = importdata (filename, delimiter, nheaderlines) loads data from ASCII file filename, reading numeric data starting from line nheaderlines + 1.
[A, delimiter] = importdata (...) returns the detected delimiter character for the input ASCII file.
[A, delimiter, nheaderlines] = importdata (...) returns the detected Number of header lines in the input ASCII file.
[...] = Importdata ('-pastespecial',...) loads data from the system clipboard rather than from a file.
----------------------------------------------------------------
This function supports the following file formats: mat files, ASCII files, spreadsheets, images, and audio files.
The ASCII files and spreadsheets refer to: For ASCII files, data contains a double array. Other Fields contain cell arrays.
For spreadsheets, each field contains a struct, with one field for each worksheet.
Import data in MATLAB: importdata Function