- When the file is not in the current working directory, a cd or chdir command may be issued to change the directory.
- >> cd a:\ % Make a:\ the current working directory
- >> d13
MATLAB Demo - %MATLAB Example use of ginput
- clear, clf, hold off
- axis ([0, 10, 0, 10])
- hold on
- plot ([1, 2, 2, 1, 1],[2, 2, 3, 3, 2])
- text (1, 1.6, 'Click inside box to quit')
- while 1
- [x, y, buttun] = ginput (1)
- if buttun == 1, plot (x, y, '+r'), end
- if buttun == 2, plot (x, y, 'oy'), end
- if buttun == 3, plot (x, y, '*g'), end
- if x > 1 & x < 2 & y > 2 & y < 3, break; end
- end
- hold off
- A MATLAB function file (called an M-file) is a text (plain ASCII) file that contains a MATLAB function and, optionally, comments.
- The file is saved with the function name and the usual MATLAB script file extension, ".m".
- A MATLAB function may be called from the command line or from any other M-file.
MATLAB Function Files - When the function is called in MATLAB, the file is accessed, the function is executed, and control is returned to the MATLAB workspace.
- Since the function is not part of the MATLAB workspace, its variables and their values are not known after control is returned.
- Any values to be returned must be specified in the function syntax.
Do'stlaringiz bilan baham: |