Borrar filtros
Borrar filtros

Read in File with Letter, Number, and Quotation Marks

1 visualización (últimos 30 días)
Sean
Sean el 4 de Abr. de 2013
Hi All,
I am trying to read in a data file that contains letters, numbers, and quotation marks (see below):
A = [1, 2, 3, 4; 5, 6, "NaN", 7; 8, 9, 10, 1]
I have done some testing using 'textscan' and am able to read in a file similar to the one above except without the quotation marks. It seems that the punctuation is tripping 'textscan' up. Is there are better way to read in the file without have to do any pre-processing?
cheers, Sean

Respuestas (1)

Ahmed A. Selman
Ahmed A. Selman el 6 de Abr. de 2013
f=fopen('Your_File','r');
Readings=fscanf(f,'c',[1,inf]);
then change the contents of (Readings) either to numbers using
Contents(i)=str2double(Readings(m:n))
where m:n indicates start:stop of the field, i indicates the place of the matrix storing the number (if needed); or leave it as char as
Content_char=Readings(m:n)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by