[SOLVED] Semi-colon not supressing output
Mostrar comentarios más antiguos
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.
%
% Example:
% 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];
end
%% 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);
end
1 comentario
Stephen23
el 6 de Feb. de 2025
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 1 de Oct. de 2022
Make sure echo is not on. Issue this command
echo off
6 comentarios
Fouad Azar
el 1 de Oct. de 2022
Image Analyst
el 1 de Oct. de 2022
Then we might need all your code to try to reproduce it, because, like @Star Strider and you said, you have semicolons after every line so they should not be echoing to the command window.
Is the whole line of code being echoed (like "echo on") or is just the results of the line being printed to the command window, like "ans = " or "opts =".
Fouad Azar
el 1 de Oct. de 2022
Image Analyst
el 1 de Oct. de 2022
Attached is what I've got.
Evidently you've got your own importData function. Or did you just misspell the built in importdata. Please include that function.
Also you forgot to attach 'dictionary.mat'
Please give me one .m file with all the functions in it that actually runs.
Fouad Azar
el 1 de Oct. de 2022
Image Analyst
el 1 de Oct. de 2022
Categorías
Más información sobre Data Import and Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!