Reading Text Files in Matlab: Formatting and Reading Specific Fields, Lecture notes of Computer Programming

Instructions on how to read text files in matlab using the textread function. It explains the different format specifications and their corresponding output types. Examples are given for reading specific fields from a text file and plotting the data.

Typology: Lecture notes

2019/2020

Uploaded on 02/01/2020

hellomynameismola
hellomynameismola 🇰🇷

2 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2019-11-07
1
Matlab
텍스트 파일 읽기
데이터 처리
텍스트 파일 읽기(textread)
메모장에서 텍스트 파일 만들기
(바탕화면에 저장)
파일 속성에서 경로 복사
텍스트 파일 읽기
[a, b, c]
=textread(C:\Users\jycho\Desktop\test.txt, %u %u %c)
pf3
pf4

Partial preview of the text

Download Reading Text Files in Matlab: Formatting and Reading Specific Fields and more Lecture notes Computer Programming in PDF only on Docsity!

Matlab

텍스트 파일 읽기 데이터 처리

텍스트 파일 읽기(textread)

[a, b, c] =textread('C:\Users\jycho\Desktop\test.txt', '%u %u %c')

format 지정

  • https://kr.mathworks.com/help/matlab/ref/textread.html 형식 동작 출력값 %d 부호가 있는 정수 값을 읽습니다. double형 배열 %u 정수 값을 읽습니다. double형 배열 %f 부동소수점 값을 읽습니다. double형 배열 %s 공백 또는 구분 기호로 구분된 텍스트를 읽습니다. 문자형 벡터로 구성된 셀형 배열 %q 큰따옴표로 묶인 텍스트를 큰따옴표를 제하고 읽습니다. 문자형 벡터로 구성된 셀형 배열 %c 공백을 포함하여 문자를 읽습니다. 문자형 배열
  • 헤드라인 제거 [a, b, c] =textread( ‘C:\Users\jycho\Desktop\test.txt', '%u %u %c‘, ‘headerlines’,1)
  • 구분자 제거 [a, b, c] =textread( ‘C:\Users\jycho\Desktop\test.txt', '%u %u %c‘, ‘delimiter’, ’,’)

temp=flipud(temp) psu=flipud(psu) yyaxis left plot(temp) yyaxis right plot(psu) legend('temp','psu') [num, kor, eng, mat, com, sci] = textread('score1.txt','%u %u %u %u %u %u','headerlines',1) max_eng=- 1 for (i=1:length(eng)) if max_eng<eng(i) max_eng=eng(i) end end disp(max_eng)