Want to delete ans from the output ou a function
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Whenever I use this function, it always spits back an ans in the command window, how do I prevent this from happening?
function [matriz, k, file] = carregar_dados (file)
file = input('Introduza o nome do ficheiro > ', 's');
fid = fopen(file);
if fid ~= -1
fprintf('O ficheiro foi aberto com sucesso! \n');
else
while fid == -1;
fprintf('O ficheiro não existe. \n');
file = input('Introduza o nome do ficheiro > ', 's');
fid = fopen(file);
end
end
k = 0;
matriz = [];
while ~feof(fid);
k = k + 1;
i = 0;
linha = fgetl(fid);
for i = 1:4;
linha(1) = [];
[valor, linha] = strtok(linha, ',)');
matriz(k,i) = str2num(valor);
end
end
fclose(fid);
end
4 comentarios
Stephen23
el 19 de En. de 2022
Editada: Stephen23
el 19 de En. de 2022
" I put a semicolon after calling the function..>"
No, you added a semi-colon in the function signature line. That will do nothing.
"and it still spits back an ans into the command window..."
Yes, because you did not put a semi-colon after the function when you call it.
"anything else I could try?"
You could put a semi-colon after the function when you call it.
But given that your function imports some data and then you assign this to ANS which you now want to ignore... I suspect that you should actually assign the function output to a variable in order to use that imported data for something.
These tutorials teach basic MATLAB concepts: https://www.mathworks.com/help/matlab/getting-started-with-matlab.html
Respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!