[SOLVED] Semi-colon not supressing output
31 views (last 30 days)
I know it's a common question here about supressing output, but I can't seem to find a missing semi-colon in my code, but yet I have a matrix displayed everytime.
The issue seems to be with the last two functions, namely table2array and readtable. This would be a minor issue if I had to import a small database, but I have hundreds of files and clc-ing everytime is just not efficient if I want to trace-back my progress.
I've attached a txt file that you can use to test the function with.
If it turns out to be a missing semi-colon, I will humbly apologize with a MATLAB Haiku 俳句。
Edit: When calling the function, I add a semi-colon.
Edit: The Issue was a semi-colon. As promised, here is my Haiku:
I was not a fool
Until semi-colon came,
Now I am a fool
function EEM = importData(filename)
%IMPORTFILE Import data from a text file
% EEM = IMPORTFILE(FILENAME) reads data from text file FILENAME for the
% default selection. Returns the numeric data.
% EEM = 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.
% EEM = importfile("C:\Users\user\Documents\Flurine\FL_DATASET\ind944h-3
% .txt", [18, Inf]);
% See also READTABLE.
% Auto-generated by MATLAB on 01-Oct-2022 12:27:26
%% Input handling
% If dataLines is not specified, define defaults
if nargin < 2
dataLines = [18, Inf];
%% Set up the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 102);
% Specify range and delimiter
opts.DataLines = dataLines;
opts.Delimiter = "\t";
% Specify column names and types
opts = setvartype(opts,"double");
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
EEM = readtable(filename, opts);
%% Convert to output type
EEM = table2array(EEM);
Star Strider on 1 Oct 2022
I do not see any missing semicolons in the file, so the most likely problem is that there is one missing when you call the function (added here):
EEM = importData(filename);
Without your code, I cannot be certain that is the problem.