2021년 5월 10일 기준.
csvwrite는 권장되지 않는다고 합니다. writematrix를 대신 사용하는걸 권장 드립니다 !
csvwrite([filename](<https://kr.mathworks.com/help/matlab/ref/csvwrite.html#mw_961756a5-b182-4f1b-8855-2003ca6a87cd>),[M](<https://kr.mathworks.com/help/matlab/ref/csvwrite.html#mw_12ae567d-3ac0-42f2-b5e6-dee7125f33cb>))
은 파일 filename
에 행렬 M
을 쉼표로 구분된 값으로 씁니다.
ex) 텍스트 파일에 값 별로 ','로 구분하여 저장할 때 사용.
csvwrite([filename](<https://kr.mathworks.com/help/matlab/ref/csvwrite.html#mw_961756a5-b182-4f1b-8855-2003ca6a87cd>),[M](<https://kr.mathworks.com/help/matlab/ref/csvwrite.html#mw_12ae567d-3ac0-42f2-b5e6-dee7125f33cb>),[row](<https://kr.mathworks.com/help/matlab/ref/csvwrite.html#mw_5f1fab50-69df-49f3-afe0-8dd820f59173>),[col](<https://kr.mathworks.com/help/matlab/ref/csvwrite.html#mw_3af131d0-4a33-472d-a50b-99bb592039cd>))
은 지정된 행과 열 오프셋에서 시작하여 행렬 M
을 파일 filename
에 씁니다. 행 인수와 열 인수는 0부터 시작하므로 row=0
과 col=0
은 파일의 첫 번째 값을 지정합니다.
ex) 위와 같고, 행 열을 추가하여 저장.
쉼표로 구분된 값(CSV) 파일에 행렬 쓰기
샘플 데이터로 구성된 배열 M
을 만듭니다.
M = magic(3)
`M = 3×3
8 1 6
3 5 7
4 9 2`
파일 'myFile.txt'
에 행렬 M
을 씁니다.
csvwrite('myFile.txt',M)