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
2
votes
2 answers

conversion of cell to matrix that contains text?

I have the text file that contains measurement data, the header is not that important so I used this to remove the first 25 lines % Skip the first 25 lines for i=1:25 fgetl(inputfile); end Then I used delimiter in order to get the data …
mecaeng
  • 93
  • 2
  • 8
2
votes
1 answer

import data from a text file in MATLAB with multiple delimiters

I try to import data from a text file to MATLAB, which has the following structure: ** Porosity ** *POR *ALL 0.1500 0.0900 2*0.1300 0.1400 4*0.1500 0.2200 2*0.1500 0.0500 0.0900 0.1400 5*0.1500 0.2300 0.2600 0.0800 0.1500 0.1500 0.2400…
2
votes
1 answer

how to find negative and positive number from a string?

I've a set of chemical reactions, and I need to read only the first number of each chemical. For example, I've a string as reaction = '-1.0CdCl2(aq) 1.0Cd++ 2.0Cl-'; I want the find -1.0 of CdCl2(aq), 1.0 of Cd++, and 2.0 of Cl-.
2
votes
2 answers

Decimating large data files from disk in MATLAB?

I have very large data files (typically 30Gb to 60Gb) in .txt format. I want to find a way to to automatically decimate the files without importing them to memory first. My .txt files consist of two columns of data, this is an example…
James Archer
  • 421
  • 2
  • 6
  • 16
2
votes
2 answers

Detect number of columns in a columnar text file

I am trying to interpret data from an eye tracking device. The files exported from the eye tracker are in ASCII format. Recording files that contain data from a single eye only look like this (only four rows shown): 6372825 645.3 275.4 1362.0…
CaptainProg
  • 5,610
  • 23
  • 71
  • 116
2
votes
2 answers

Cannot import all values at once in Matlab using TextScan

I have a dataset of 1911518 values. I have used the textscan function. But the function returns only 1424458 values. I again created a new variable to get the remaining values but this time it gave me around 9000 values. Does anyone know what the…
user2848498
  • 57
  • 2
  • 7
2
votes
1 answer

textscan strange behaviour in matlab

I have a code that i'm trying to run in matlab, it gives an error in textscan function as it can't split a string on a delimiter, although i'm sure the code works on other versions of matlab (on other computer) >> a='ahmed;mohamed' a…
Ahmed Kotb
  • 6,269
  • 6
  • 33
  • 52
2
votes
1 answer

Matlab textscan with fixed width

I have to read a file like this 10001 3 5.0000 30.0 0.0000 25.6 0.0000 10.0 10002 1 25.0000 0.0000 4.6887 58.2 10003 5 45.0000 20.0 …
2
votes
1 answer

MATLAB textscan headerlines

When I try to use headerlines with textscan to skip the first line of the text file, all of my data cells are stored as empty. fid = fopen('RYGB.txt'); A = textscan(fid, '%s %s %s %f', 'HeaderLines', '1'); fclose(fid); This code gives 1x4 Cell []…
Mark Hughes
  • 245
  • 2
  • 5
  • 11
2
votes
1 answer

how to concatenate disparate values loaded by textscan()?

I am loading some text with textscan, and although the data comes through, I would like to convert that data into a matrix of floats instead of the hh:mm:ss format. Here is an example of the data: 2010/01/01,00:00:00.979131, 27.4485, 51.9362,…
jml
  • 1,745
  • 6
  • 29
  • 55
2
votes
2 answers

How to separate float with string that are togetter written - matlab

I have a question regarding to read a txt file in matlab were the format is not know , but each row in the txt file always start like this: 2012-11-01 00:00:00.00 XX YY 00.000s Then some different stuff is logged and the txt file can look…
user1564762
  • 745
  • 2
  • 11
  • 18
2
votes
1 answer

Matlab textscan gone wrong: cellfun to select data from certain lines

Hi I am using the following code to read some values from lines containing 'GPGGA' from data.txt fid = fopen('D:\data.txt','r'); A=textscan(fid,'%s %*s %f %s %f %s %*s %*s %*s %*s %*s %*s %*s %*s %*s,'Delimiter',','); fclose(fid); Loc = [A{[2,…
2
votes
2 answers

Cutting off textscan after a character

I'm working on a function in MATLAB that reads input from a file. So far (after reading a bit here about scanf vulnerabilities) I decided to use fgets to get each line, and then textscan to extract the words, which will always be of the format…
Andrew
  • 1,839
  • 14
  • 25
1
vote
1 answer

Importing data without headers and rearranging column data

I have a 100 .dat files like the one in the left hand pane, which I need to import without headers and then sort rows. ANSWER for doing it manually, file by file: data=sortrows(data,2); #sort all columns of data via the 2nd…
HCAI
  • 2,213
  • 8
  • 33
  • 65
1
vote
2 answers

Average of values from a column/ Skip lines (textscan)

I have a .txt file which looks like this: ******text******* (30 lines containing text and *) ******text******* a b c a b c a b c a b c a b c a b c a b c (I'm creating a plot with a as x and b and c as y1 and y2) How do I skip those 30 lines with…
Dywabo
  • 49
  • 6
1 2
3
14 15