필터 지우기
필터 지우기

how can I edit txt file?

조회 수: 2 (최근 30일)
Muhsin
Muhsin 2017년 2월 4일
댓글: Walter Roberson 2017년 2월 5일
Hello; I am a new user.Can anyone help me edit the txt file that is attached. there are eight columns in the file and I would like to make one column. The order should be from left to right. After first row has been put in order in the column, the command should do the same the for second row. Hope this is a clear explanation. Thank you. Regards, Muhsin A
  댓글 수: 2
Image Analyst
Image Analyst 2017년 2월 4일
It would certainly be a lot easier if you could have the file written out with a delimiter between the numbers. Is that possible?
Muhsin
Muhsin 2017년 2월 4일
편집: Muhsin 2017년 2월 4일
Yes, I can put a space between columns. Would you want me to do that? But please keep in mind It shouldn't be column by column.

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

채택된 답변

Image Analyst
Image Analyst 2017년 2월 4일
This works:
txt = fileread('mineral 90.txt');
numbers = cell2mat(textscan(txt, '%f')) % Convert text to doubles.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 4일
Once you have the data read in to variable DATA, then DATA.' would rearrange it with the data down the columns instead of across the rows.
  댓글 수: 14
Muhsin
Muhsin 2017년 2월 5일
편집: Muhsin 2017년 2월 5일
Dear Walter;
Should't that 'new(1:8,:)' command give me the whole numbers in the columns instead of only first row of the columns??
Walter Roberson
Walter Roberson 2017년 2월 5일
It is showing you all of the columns, which is to say all 1 of them. You have been vague about what you want the output to be.
DATA.'
would switch all the rows and columns, giving you 8 rows and over 2000 columns.
reshape(DATA.',[],1)
will give you a single column result which is the elements from the first row first, then the elements from the second row, then the elements from the third row, and so on.

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

카테고리

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