카테고리 없음2014. 8. 29. 11:28

Standard dialog boxes to select files or directory locations for loading and saving data as you know them from other applications are also available in Matlab.

help

All of them have a large number of configuration options, which cannot be discussed in detail here, thus only some typical application examples are shown. For further options, please consult the Help System.

Select a file: uigetfile

[FileName, PathName] = uigetfile('*.m', 'Select the M-file');

Opens the file selection dialog box. The function returns the file name and the path. If «Cancel» has been clicked, FileName = 0 results.

The first argument '*.m' is a filter, i.e. only files with this extension are shown. If all files should be visible, '*.*' can be entered. The second argument contains the text that will be shown in the window title.
The selection process begins at the current path as it is set in Matlab as the «Current Directory».

If you want the selection to start at a different place in the file system, you can specify it like this:

[FileName,PathName] = ...
uigetfile('d:\matlab\data\*.txt', 'Select data set');

If several file types should be available, you can specify this by means of a cell array. The desired file extensions are listed in the first column of the cell array:

[filename, pathname] = ...
uigetfile({'*.m'; '*.mdl'; '*.mat'; '*.*'}, 'File Selector');

act

Example for a file selection dialog with output of the result. Copy the code lines below into the Command Window (>> can also be copied - Matlab will ignore them).

>> [filename, pathname] = uigetfile('*.txt', 'Pick a text file');
>> if isequal(filename, 0)
>> disp('User selected ''Cancel''')
>> else
>> disp(['User selected ', fullfile(pathname, filename)])
>> end

Resulting file selection windowResulting file selection window

Select a directory: uigetdir

directory_name = uigetdir('c:\data\', 'Please select the directory')

Opens a directory selection dialog box directory_name contains the selected path. If the user hits «Cancel», the value 0 is returned.
The first argument designates the path where the selection process starts out. The second argument holds the window title text.

Directory selection windowDirectory selection window

Select a directory/file name to save a file: uiputfile

[FileName, PathName] = uiputfile('*.dat', 'Save as...')
[FileName, PathName] = uiputfile('vp27data.dat', 'Save as...')

Creates a dialog box to select the location for a file saving operation. The function returns the selected file name and path. In case «Cancel» has been pressed, FileName = 0 results.
The first argument specifies the file type; in the second example, a complete file name is suggested. The second argument again specifies the window title text.

Window to select the location to save a fileWindow to select the location to save a file

Two useful functions to handle file and path names

Often, the queried file names have to be disassembled into their parts, or a complete path has to be assembled from parts. To aid this, there are helpful functions:

act

Please try it out for yourself.

Decompose a complete path into its constituents:fileparts

>> [pathstr, name, ext] = fileparts('c:\data\new\myfile.txt')

And the converse: Generate a complete path from parts: fullfile

>> filepath = fullfile(pathstr, [name ext])
>> filepath = fullfile('C:', 'data', 'new', 'myfile.txt')



Posted by 오늘보다 나은 내일
카테고리 없음2014. 8. 26. 09:56

Batch File을 이용해야 하는 일이 생겼다.


taskkill /f /im  xxxxxxxx.exe


아래는 퍼온 내용



Posted by 오늘보다 나은 내일
카테고리 없음2014. 8. 19. 15:20

1. char 함수 -- 2차원 문자 배열을 생성(배열의 각 행의 길이가 달라도 가능) 

title = ['title 12';'title 20'] ==> o

title = ['title 1'; title 10'] ==> x 

title = char('title 1','title 10') ==> 자동으로 공백을 덧붙여서 길이를 맞춘다.

title =

title 1 

title 10


2. deblank 함수  -- 문자열 끝에 붙은 공백을 제거

title = 'title 12  '; ==> 길이 10

title_trim = deblank(title); ==> 길이 8


3. strcat 함수 -- 두개 이상의 문자열을 연결한다. 문자열 끝에 붙은 공백은 제거

strresult = strcat('string1 ','string2 '); ==> 길이 8+8에서 결과는 7+7


4. strvcat 함수 -- 두개 이상의 문자열을 수직으로 배치하고 가장 긴 문자열 길이에 맞게 공백을 추가

strresult = strcat('string11 ','string2 '); ==> 길이 9,8 문자열의 결과 9,9 


5. strcmp 함수 -- 두 문자열이 같으면 1 다르면 0을 반환

result = strcmp('string1','string2'); ==> 두 문자열이 다르므로 0 반환


6. strcmpi 함수 -- 대/소문자 구별없이 두 문자열이 같으면 1 다르면 0을 반환

result = strcmpi('string1','STRING1'); ==> 대소문자 구별이 없으므로 1 반환


7. strncmp 함수 -- 처음부터 n개의 문자가 같은지 판별

result = strncmp('string1','string2',6); ==> 6번째까지 문자열이 string으로 동일하므로 1 반환


8. strncmpi 함수 -- 대/소문자 구별없이 처음부터 n개의 문자가 같은지 판별

result = strncmpi('string1','STRING2',6); ==> 6번째까지 문자열이 대소문자 구별없이 string으로 동일하므로 1 반환

result =

     1

 

9. isletter 함수 -- 문자가 글자면 1 아니면 0을 logical 벡터로 반환

isletter('1a')

ans =

     0     1


10. isspace 함수 -- 문자가 여백 문자면 1을 아니면 0을 logical 벡터로 반환

isspace('1 a\')

ans =

     0     1     0     0


11. isstrprop 함수 -- 문자가 사용자가 지정한 범주에 속하면 1을 아니면 0을 반환

isstrprop('1 a','alphanum') ==> 알파벳과 숫자면 1을 아니면 0을 반환 

ans =

     1     0     1


isstrprop('\''[]:,-!().?";','punct') ==> 문자가 구두점이라면 1을 아니면 0을 반환

ans =

  Columns 1 through 10

     1     1     1     1     1     1     1     1     1     1

  Columns 11 through 14

     1     1     1     1

*2번째 인자

' alpha' --> 알파벳이면 1 아니면 0

'cntrl' --> char(0:20)에 속하는 제어 문자이면 1 아니면 0

'digit' --> 숫자이면 1 아니면 0

'graphic' --> 그래픽문자이면 1 아니면 0

'lower' --> 소문자이면 1 아니면 0

'upper' --> 대문자이면 1 아니면 0

'wspace' --> white-space 문자이면 1 아니면 0 {' ','\t','\n','\r','\v','\f'}

'xdigit' --> 16진수문자면 1 아니면 0

 

12. findstr 함수 -- 두 문자열 중에서 짧은 문자열이 긴 문자열에 나타나는 인덱스를 반환

findstr('matlab matrix','ma')

ans =

     1     8


13. strmatch 함수 -- 2차원 문자열 배열의 각 행의 처음을 조사하여 지정된 문자열로 시작하는 행의 목록을 반환

string = strvcat('matlab','matrix','min');

strmatch('ma',string)

ans =

     1

     2 


14. strrep 함수 -- 문자열에서 다른 문자열을 찾은 후에 다른 문자열로 대체

strrep('matlab matrix','matrix','matlab')

ans =

matlab matlab


15. strtok 함수 -- 구분문자가 처음 나타나기 전의 문자열을 반환

[token,remainder] = strtok('matlab matrix',' ')

token =

matlab


remainder =

 matrix  


16. upper 함수 -- 모든 알파벳 문자를 대문자로 변환

17. lower 함수 -- 모든 알파벳 문자를 소문자로 변환


18. strtrim 함수 -- 문자열 앞뒤에 붙은 여백문자들을 모두 제거

strtrim('  matrix  ')

ans =

matrix


19. int2str 함수 -- 스칼라값을 문자열로 변환

20. num2str 함수 -- double형을 문자열로 변환

21. mat2str 함수 -- matrix를 문자열로 변환

22. sprintf 함수 -- 서식화된 데이터를 문자열로 변환


23. eval 함수 -- 문자열을 MATLAB 식으로 간주하여 값을 반환

a = '2*pi';

b = eval(a)

b =

    6.2832


24. str2double 함수 -- 문자열을 double형으로 변환

25. str2num 함수 -- 문자열을 수치로 변환

26. sscanf 함수 -- 문자열로부터 서식화된 데이터로 변환



출처 : http://babytiger.tistory.com/entry/MATLAB-%EB%AC%B8%EC%9E%90%EC%97%B4%EA%B3%BC-%EA%B4%80%EB%A0%A8%EB%90%9C-%ED%95%A8%EC%88%98%EB%93%A4

 

Posted by 오늘보다 나은 내일