Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Script stops running after reaching blank value during import
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to import data programmatically from a file but whenever the file reaches one of the lines without numbers that still contains the formatting the script seems to freeze and finishes running. The code I'm using is below while the contents of the text file are below that. I know that the problem are the lines that consist of $$ & #$ && with no number values because when I pause the script from running the matrix created stops there. Can anyone see what I'm doing wrong or have a solution? Thank you
clear
clc
mat=[]
filename='GroupFTest.txt'
fileID=fopen(filename)
while ~feof(fileID)
nextrow = fscanf(fileID, '$$%f& %f#$ %f&&\n',3);
nextrow = nextrow';
mat = [mat; nextrow];
end
mat
$$0.64& 0.56#$ -0.23&&
$$0.83& 0.72#$ -0.45&&
$$0.73& 0.13#$ -0.04&&
$$0.17& 0.97#$ -0.43&&
$$0.93& 0.67#$ -0.24&&
$$0.48& 0.12#$ -0.36&&
$$0.94& 0.78#$ -0.20&&
$$ & #$ &&
$$0.56& 0.44#$ -0.34&&
$$0.75& 0.43#$ -0.37&&
$$0.65& 0.34#$ -0.46&&
$$0.45& 0.61#$ -0.56&&
$$0.67& 0.12#$ -0.89&&
$$ & #$ &&
$$0.52& 0.87#$ -0.65&&
$$0.23& 0.44#$ -0.34&&
0 comentarios
Respuestas (1)
John Doe
el 10 de Oct. de 2019
I use readtable for delimited text files. I've found this to work very well.
Can you share the original format please if you want more specific help.
Here is an example which should solve your problem:
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!