-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathimport_dataset_2019b.m
48 lines (39 loc) · 2.08 KB
/
import_dataset_2019b.m
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
function dataset = importfile(filename, dataLines)
%IMPORTFILE Import data from a text file
% DATASET = IMPORTFILE(FILENAME) reads data from text file FILENAME for
% the default selection. Returns the data as a table.
%
% DATASET = IMPORTFILE(FILE, DATALINES) reads data for the specified
% row interval(s) of text file FILENAME. Specify DATALINES as a
% positive scalar integer or a N-by-2 array of positive scalar integers
% for dis-contiguous row intervals.
%
% Example:
% dataset = importfile("dataset.csv", [2, Inf]);
%
% See also READTABLE.
%
% Auto-generated by MATLAB on 25-May-2020 12:26:14
%% Input handling
% If dataLines is not specified, define defaults
if nargin < 2
dataLines = [2, Inf];
end
%% Setup the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 24);
% Specify range and delimiter
opts.DataLines = dataLines;
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["distance", "altitude", "Var3", "tx_beam", "rx_beam", "Var6", "Var7", "Var8", "Var9", "Var10", "Var11", "Var12", "tx_gain_idx", "rx_rf_gain_idx", "rx_if_gain_idx", "stf_snr", "post_snr", "rssi", "rssistd", "txtemp", "rxtemp", "eirp", "pRx", "path_loss"];
opts.SelectedVariableNames = ["distance", "altitude", "tx_beam", "rx_beam", "tx_gain_idx", "rx_rf_gain_idx", "rx_if_gain_idx", "stf_snr", "post_snr", "rssi", "rssistd", "txtemp", "rxtemp", "eirp", "pRx", "path_loss"];
opts.VariableTypes = ["double", "double", "string", "double", "double", "string", "string", "string", "string", "string", "string", "string", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Specify variable properties
opts = setvaropts(opts, ["Var3", "Var6", "Var7", "Var8", "Var9", "Var10", "Var11", "Var12"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["Var3", "Var6", "Var7", "Var8", "Var9", "Var10", "Var11", "Var12"], "EmptyFieldRule", "auto");
% Import the data
dataset = readtable(filename, opts);
end