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

How do i read text file using command textscan

I have a rather large text file (over 2050 lines x 4080 columns) that has the following format: #1 #2 #3...........#10 #1 #2 #3...... Time 21:22:10 21:23:56 21:23:07....06:19:11 06:21:00 06:21:23 06:23:01...... 15 …
0
votes
2 answers

How to extract time, lat, lon, from a filename using textscan in matlab

I am sorry, but I am really hopeless here using textscan and the format. I kept trying various way of getting the correct format to extract the time, lat, and lon from the following text; filename =…
sophie
  • 115
  • 1
  • 7
0
votes
1 answer

Read data row wise from a file(.txt or .dat) in matlab

I want to read a row with numeric data from a file which contains one text line and few lines with numeric data. I have tried this by using fopen and textscan(as all string value) command in MATLAB. After loading all the data and trying to do any…
0
votes
2 answers

MATLAB READING FILE

i am having trouble reading the file, basically, i want to somehow get rid of the unnecessary text and just print out a matrix involving only the numbers. 1 1 -1 1 1 -1 -1 1 1 1 -1 1 1 -1 1 -1 -1 …
0
votes
2 answers

Replace a line containing a special character with nan using textscan in matlab

I am trying to read a file using textscan containing following lines 1.0 2.0 3.0 ? 6.0 5.0 11.0 12.0 13.0 15.0 16.0 15.0 21.0 22.0 23.0 25.0 26.0 25.0 31.0 32.0 33.0 ? 36.0 35.0 How can I replace the question marks with nan?
Rachel
  • 305
  • 2
  • 12
0
votes
1 answer

Matlab Text File Delimiter and Header Readin

I have a file that looks like this: RD|Action Code|State Code|County Code|Site ID|Parameter|POC|Sample Duration|Unit|Method|Date|Start Time|Sample Value|Null Data Code|Sampling Frequency|Monitor Protocol (MP) ID|Qualifier - 1|Qualifier - 2|Qualifier…
SugaKookie
  • 780
  • 2
  • 17
  • 41
0
votes
0 answers

MATLAB - Creating a repeating textscan process which runs until an entire file has been dealt with

I'll start out by saying that I'm something of a Matlab newbie so I apologise if this question has been asked before but I have been unable to find the answer I need. I'm working on a code to process some large Rainfall Radar files (5-20GB), I have…
IdleSam
  • 13
  • 4
0
votes
2 answers

Matlab - Help using text scan, how to ignore comments and header columns?

I need help using text scan. I am trying to read data that has the following format: # ---------------------------------- WARNING ---------------------------------------- # The data you have obtained from this automated U.S. Geological Survey…
Hooplator15
  • 1,540
  • 7
  • 31
  • 58
0
votes
1 answer

Use textscan in Matlab to output data

I've got a large text file with some headers and numerical data. I want to ignore the header lines and specifically output the data in columns 2 and 4. Example data [headers] line1 line2 line3 [data] 1 2 3 4 5 6 7 8 9 10 11 12 I've…
0
votes
1 answer

textscan stops reading after 1 line

I'm using the following command to read a csv file: fid=fopen('test.csv'); scannedData = textscan(fid, '%4.0u%2.0u%2.0u%2.0u%2.0u%2.0u,%u,%u,%q,%q,%f,%f,%.2f,%u','whitespace','"'); fclose(fid); The problem is that textscan doesn't read the value…
0
votes
0 answers

Reading a txt file of unknown length and mixed content

I am trying to have Matlab read a .unv file (which is seems to open just fine and treats as a .txt) and gather data. An example from the first part of the file is as follows: -1 151 bricktest.unv CUBIT version 14.0 revised 2013-06-01 09:06:37…
0
votes
1 answer

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

I have a text file that i need to read in that has different number of columns of hex data depending on the row. I am trying to read it all in and then manipulate the hex, but I can seem to find a good way to read the file in. I want to read in the…
user2540100
  • 1
  • 1
  • 1
0
votes
1 answer

Read a specific part of a txt file for each line

I have a txt file in which lots of information is given. I want to read and store just 'status' part. Example: id........username...... status......language .......image 11111 abcdefg Man Utd won for the second time ENG img1244 11112 abcdaaa Man…
0
votes
1 answer

MatLab using "for" and "if" for string

I have text.txt which contains words and numbers. 1. I want to use "for" and "if" for cells or matrices which contain string. d = reshape(textread('text.txt','%s','delimiter','\t'),2,2)' if h(1,1)=='apple' k=1 end This didn't work. 2. I want…
user1849133
  • 527
  • 1
  • 7
  • 18
0
votes
2 answers

How do I read several lines in Matlab with textscan?

I used this : weights=fopen('indices.txt'); weights=textscan(weights, '%d %d %d %d %d %d %d') but this only reads the first line of my file. my file looks like this : 0 90 100 5 0 0 0 (class) 19 5 0 0 0 0 0 (class2) 5 5 0 0 0 0 0 (class3) -10 -5 0…
Lay
  • 249
  • 1
  • 3
  • 15
1 2 3
14
15