User-defined Functions (2/28) Scripts All of the M-files that we have seen so far have been script files Editor-C\MATLAB7\work\distance.m File Edit Text Cell Tools Debug Desktop Window He D三■品意口~昌的天.自超习 1-xl=input ('the first point x'); 2- yl=input('the first point y'): 3- x2=input('the second point x'); 4- y2=input ('the second point y); 5- d=sqrt(x1-x2)2+(y1-y2)2): 6 disp(['the distance is'num2str(d)]); A script is just a collection of MATLAB statements Running a script is the same as running the statements in the command window A special type of M-file ---Function 同濟大学 AW TONGJI UNIVERSITY All of the M –files that we have seen so far have been script files A script is just a collection of MATLAB statements Running a script is the same as running the statements in the command window A special type of M-file --- Function User-defined Functions (2/28) Scripts