Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Importing 2 .txt files within the one import command

2 visualizaciones (últimos 30 días)
bugatti79
bugatti79 el 16 de Oct. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi Folks,
How do I import 2 different .txt files containing numbers using the one import command as a function. Here is my code, it only imports the 2nd txt file for some reason.
function importfile(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Auto-generated by MATLAB on 16-Oct-2013 20:59:38
DELIMITER = '\t';
HEADERLINES = 5;
% Import the file
Test = importdata('Name1.txt', DELIMITER, HEADERLINES);
% Create new variables in the base workspace from those fields.
vars = fieldnames(Test);
for i = 1:length(vars)
assignin('base', vars{i}, Test.(vars{i}));
end
DELIMITER = '\t';
HEADERLINES = 5;
% Import the file
Test2 = importdata('Name2.txt', DELIMITER, HEADERLINES);
%Create new variables in the base workspace from those fields.
vars = fieldnames(Test2);
for i = 1:length(vars)
assignin('base', vars{i}, Test2.(vars{i}));
end
end
Also I would like to have a unique name for each imported matrix. Thanks in advanced. B

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by