치트시트

MATLAB을 사용한 데이터 가져오기 및 내보내기​

MATLAB은 다양한 형태의 데이터를 읽고 쓸 수 있는 기능을 제공합니다. 이 참조 자료는 일반적인 활용 사례를 중심적으로 소개하며, 제공되는 모든 기능에 대한 포괄적인 목록은 아닙니다.​

가져오기 툴

가져오기 툴을 실행하려면 데이터 가져오기를 선택합니다.

저수준 I/O

fgetlfscanf와 같은 저수준 함수는 I/O에 대한 보다 직접적이고 정밀한 제어를 제공합니다.​

fid = fopen('myfile.txt'); 
data = fscanf(fid,'%f %q'); 
fclose(fid); 

형식 사양​

유형 지정자 출력 클래스

부호 있는 정수

부호 없는 정수

%d,%d8,…

%u,%u8,…

int32,int8

uint32,uint8

부동소수점 

%f

%f32

double

single

텍스트 배열

%s, %q

'TextType'

string

날짜/시간

%D,%{fmt}D

datetime

기간

%T,%{fmt}T

duration

범주

%C

categorical

패턴

%[…]

string

필드 건너뛰기

%*k

 

표준 파일 형식

대용량 또는 다수의 파일에는 데이터저장소를 사용합니다. fileDatastore는 모든 유형의 파일에 사용할 수 있습니다. 데이터 읽기 방식에 대해 보다 정교한 제어가 필요한 경우 사용자 지정 데이터저장소를 사용할 수 있습니다.

특화된 I/O 지원은 여러 애드온 제품(Simulink, Database Toolbox, Vehicle Network Toolbox기타)에서 찾을 수 있습니다. 추가 기능에 대해서는 File ExchangeGitHub을 참조하십시오.

유형 단일 파일 다중 파일 쓰기 고급

텍스트

readtable

tabularTextDatastore

writetable

detectImportOptions

textscan

스프레드시트

readtable

spreadsheetDatastore

writetable

detectImportOptions

.mat

load matfile

fileDatastore

save

Custom datastore

영상

imread

imageDatastore

imwrite

Custom datastore

비디오

VideoReader

fileDatastore

VideoWriter

Custom datastore

오디오

audioread

fileDatastore

audiowrite

Custom datastore

NetCDF

ncread

fileDatastore

ncwrite

netcdf

CDF

cdfread

fileDatastore

cdfwrite

cdflib

HDF5

h5read

fileDatastore

h5write

H5, H5F, …

XML

xmlread

fileDatastore

xmlwrite

Custom datastore

이진

fread

fileDatastore

fwrite

Custom datastore

웹 데이터

RESTful 웹 서비스

webread

데이터 읽기

webwrite

데이터 쓰기

websave

파일에 데이터 저장

weboptions

인증 및 시간 초과와 같은 옵션 지정

JSON     

jsondecode jsonencode

HTTP 메시징

더 복잡한 웹 통신에는 HTTP 인터페이스를 사용할 수 있습니다.

body = matlab.net.http.MessageBody(x);
request = matlab.net.http.RequestMessage(method,header,body);