필터 지우기
필터 지우기

how to read numbers in txt file (numbers with space and colons)

조회 수: 6 (최근 30일)
Ben
Ben 2017년 6월 26일
편집: per isakson 2017년 6월 26일
Hi:
I have a text file that has following format of the numbers
A1 B11:C11 B12:C12 B13:C13... (carrier return)
A2 B21:C21 B22:C22 B23:C23... (carrier return)
A3 B31:C31 B32:C32 B33:C33... (carrier return)
.....
A is interger (1-6 digits). B is xxx.xx or xx.xx. C is 1 to 5digits of interger. The goal is to read all of lines (it has different number of columns) and put them into a matrix. How to read all of the numbers here delimited with spaces and columns? Many thanks.
  댓글 수: 1
Jan
Jan 2017년 6월 26일
편집: Jan 2017년 6월 26일
I've used the "{} Code" button to format the contents of the file. Did you see, that the auto-linebreaks of the forum made it unreadable? I cannot understand, why so many user do not care, if their question is not readable. Isn't it the vital interest of a question to be as easy to understand as possible?
What does " B is xxx.xx or xx.xx" mean? Does "C11" and "C is 1 to 5digits of integer" mean e.g. "1234511"? What exactly does "..." stand for?
Please post a small example of the real data.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jess Lovering
Jess Lovering 2017년 6월 26일
You can try to use the import GUI (button on toolbar) to import the data and also generate a script that you can use as an example and use in the future. It's pretty simple to use. For instruction type "doc import tool" at the prompt.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by