Questions tagged [textscan]

Matlab function for reading formatted data.

textscan is a Matlab function for reading formatted data from text file or string.

For more details, see the Matlab's official doc.

222 questions
3
votes
2 answers

Importing .csv data to matrix

I have a .csv file with the following 'configuration' 'string', 'string', 'string', 'string', 'string' 'string', 'string', 21, 89, 67 'string', 'string', 45, 12, -16 'string', 'string', 78, 56, 45 'string', 'string', 23, 65, 90 'string', 'string',…
Johnny Doe
  • 45
  • 4
3
votes
2 answers

matlab parse file into cell array

I have a file in the following format in matlab: user_id_a: (item_1,rating),(item_2,rating),...(item_n,rating) user_id_b: (item_25,rating),(item_50,rating),...(item_x,rating) .... .... so each line has values separated by a colon where the value to…
anonuser0428
  • 11,789
  • 22
  • 63
  • 86
3
votes
1 answer

Textscan skips desired white space at begin of line

To run a certain software I'm using .txt-input files which I need to manipulate with Matlab. I know how to do it, and I didn't expected problems. As it was not working I reduced my manipulation script to a minimum, so actually nothing is changed.…
Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
3
votes
1 answer

Extract numerical array from char array in the most general way in Matlab

I know there are already a lot of questions about this topic out there. But all solutions are for certain cases. I try to find a highly generalized way to extract numerical data from cell arrays containing char. Example data: lines = <779x88 char>…
Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
3
votes
2 answers

How do I read a text file with variable hexadecimal value columns in matlab?

I have a rather large text file (over 16,000 lines) that has the following format: #ID #Line Num #Var Col Length Values (HEX): 45 00001 FFFF FFFF 0000 0000 45 00002 0000 0000 FFFF FFFF 47 00003 …
James Mertz
  • 8,459
  • 11
  • 60
  • 87
3
votes
1 answer

textscan on columns in a csv file with columns for flaggin data, delimiter issue

I am reading many csv files and extracting columns 1, 6, 8, and 20. The delimiter is '","' because the csv is using double quotes. This is working great unless some of the data is flagged, in which case the everything is thrown out of whack. Data…
3
votes
1 answer

Changing from textread to textscan MATLAB

I've problem changing my code that uses textread function to textscan. Contents of data.txt:(Note:I've changed all actual coordinates to…
2
votes
1 answer

textscan in MATLAB: read NULL value as NaN

I have a .txt file with the following data: sampleF.txt --> (tab delimited) MSFT 200 100 APPL 10 NULL AMZN 20 40 I need to read this data using textscan. I am facing a problem while reading the NULL data. Using treatasempty param,…
Maddy
  • 2,520
  • 14
  • 44
  • 64
2
votes
4 answers

Matlab: How can I read in a string separated with spaces but ignore single spaces (using textscan)?

Hi all and thanks in advance. This is my first post here, please let me know if I should do this differently. I have a large textfile containing lines like the following: "DATE TIMESTAMP T W M T AL M C A_B_C" At first I read this in…
Birk Birk
  • 21
  • 1
  • 1
  • 2
2
votes
2 answers

read complicated .txt file into Matlab

I would like to read a .txt file into Matlab. One of the columns contains both letters and numbers. (So I guess one way is to read this column is as string.) The problem is I also need to find out numbers which are larger than 5 within that…
Zoe
  • 21
  • 1
  • 2
2
votes
2 answers

MATLAB: how to read every Nth line of a text file?

I have some data that's formatted as follows: dtau E_av variance N_sims Time 0.001 0.497951 0.000211625 25 Sun Apr 3 18:18:12 2011 dtau E_av variance N_sims Time 0.002 0.506784 0.000173414 25 …
trolle3000
  • 1,067
  • 2
  • 14
  • 27
2
votes
1 answer

GNU Octave: reading data with NA values using textscan(...)

I need to read data from an ASCII file where missing values are given as NA. Using textscan(...) does not seem to work, because textscan(...) seems to stop reading/parsing at the first occurrence of NA. Here's a simple demonstration of the issue: x…
mbrennwa
  • 581
  • 1
  • 3
  • 11
2
votes
1 answer

How to read data using a custom delimiter

Related to this question, I have this data sample saved in a .txt file: '1458937887.70818 $GPGGA,200228.90,3555.3269,N,15552.9641,A*25' '1458937887.709668 $GPVTG,56.740,T,56.740,M, 0.069,N,0.127,K,D*2D' '1458937887.712022…
user3842532
2
votes
1 answer

Reading large amount of data stored in lines from csv

I need to read in a lot of data (~10^6 data points) from a *.csv-file. the data is stored in lines I can't know how many data points per line and how many lines are there before I read it in the amount of data points per line can be different for…
Fugu_Fish
  • 131
  • 2
  • 10
2
votes
1 answer

cell array to numeric array for plotting

I have a cell array containing historic gold price data and a cell array with the associated dates. I want to plot dates against prices for simple analysis but I am having difficulty converting the cell array of prices into a doubles. My code…
Adam
  • 93
  • 1
  • 1
  • 9
1
2
3
14 15