matlab 3

[MATLAB] copyfile 파일복사하기

input.txt를 output.txt 로 통채로 카피하고 싶을때 (파일의 종류는 무엇이 되든 상관없음. 사진이든 뭐든 상관없음)) copyfile('input.txt','output.txt'); 주의, copyfile의 두 인자는 파일의 이름 (m파일과 같은 폴더에 있는 경우) 혹은 주소를 넣어주어야 한다. COPYFILE Copy file or directory. [SUCCESS,MESSAGE,MESSAGEID] = COPYFILE(SOURCE,DESTINATION,MODE) copies the file or directory SOURCE to the new file or directory DESTINATION. Both SOURCE and DESTINATION may be either an abso..

[MATLAB] textscan 파일에 쓰여진 문자열 읽기

img.txt 라는 파일에 아래 내용이 저장되어 있다고 하자. D:\DB\oxford\jpg\bark_img1.jpgD:\DB\oxford\jpg\bark_img2.jpgD:\DB\oxford\jpg\bark_img3.jpgD:\DB\oxford\jpg\bark_img4.jpgD:\DB\oxford\jpg\bark_img5.jpg load(img.txt) 를 사용하면 에러 발생 (숫자만 읽어들일 수 있다고 한다) fopen , fread 혹은 fscanf 해서 한라인씩 읽어들이려니 설정해줄 것도 많고 귀찮다. 조금 잘못하면 에러 난다... textscan 함수를 사용해보자. fp = fopen('img.txt','r');imFilelist = textscan(fp,'%s') 여기서 imFilelist는 ..

[MATLAB] 문자열 바꾸기 strrep

newstring = strrep(orgstring, word1,word2) strrep 함수는 orgstring에서 word1을 찾아서 word2로 바꾸어 newstring에 저장한다. 예제) str1 = 'lonesome';str2 = strrep(str1,'lone', 'awe'); 결과 str2 = 'awesome' STRREP Replace string with another. MODIFIEDSTR = STRREP(ORIGSTR,OLDSUBSTR,NEWSUBSTR) replaces all occurrences of the string OLDSUBSTR within string ORIGSTR with the string NEWSUBSTR. Notes: * STRREP accepts input co..