Download presentation
Presentation is loading. Please wait.
Published byRudolf Richards Modified over 9 years ago
1
P ROCESSING D ATA U SING MATLAB Dr. Nawaporn Wisitpongphan 1
2
O UTLINE Function in MATLAB Lab #1: Easy “Hello World” Function Lab #2: Function with input/output Reading Data from File Lab #3: Read file using load command Lab #4: Read file line by line using fgetl Writing Data to File Lab #5: Preparing data Plotting Data Lab #6: Creating 2-D plot Lab #7: Creating 3-D plot Data Manipulation Lab #8: Scalar, array, matrix 2
3
F UNCTIONS IN MATLAB Creating M-File Lab #1: create M-File to print “Hello World…” File->M-File Use the function named :HelloWorld Useful Command: disp Lab #2: Print the word Hello World… according to the input number Modify HelloWorld to Take integer number “n” as input Use for loop to print Hello World “n” number of times Output -> the number of alphabets including space and full stop Useful Command: strcat num2str, str2num for, while, size, length 3
4
R EADING D ATA FROM A FILE : L AB 3.1 Useful Command load mean, std, min, max strfind Lab#3.1: Read student’s score from file using load command Open GroupA.txt GroupB.txt and GroupC.txt Display output according to given format 4
5
R EADING D ATA FROM A FILE : L AB 3.2 Lab#3.2: Read student’s scores from file using load command Open file sGroupA2.txt GroupB2.txt and GroupC2.txt Let the input be the file name and the word “Midterm” or “Final” Display output according to the given format 5
6
R EADING D ATA FROM A FILE : L AB 4 Useful Command: fopen, fgetl, fgets, fread, fscanf If, else strtok, strtrim, strcmp disp Lab #4 Read the students’ scores using fgetl command Open and read file “lab4.txt” The input should be “file name” and “grade” Print the score of all the students who got that grade 6
7
W RITING D ATA TO F ILE : L AB 5 Lab #5 Use Data from lab 4 Recreate the new data file by removing the first text line and the grade column (see the format on the right) The input to the function should be the name of the file from Lab 4 and the name of the new data file 7
8
P LOTTING D ATA : L AB 6 & 7 Useful Command: figure, plot, subplot, hist, bar hold on, hold off xlabel, ylabel, title, legend, grid set Lab #6 & 7 & 8: Read file from lab6.txt column #1 = ID Column #2 = Midterm Score Column #3 = Final Score Column #4 = Total Score 8
9
L AB 6.1 Lab 6.1 plot 2-D graph using plot command X-axis = ID Y-axis = Midterm and Final score Use hold on and hold off to overlay the graphs 9
10
L AB 6.2 Lab 6.2 1 st plot = use hist command with bin size = 5 on midterm score 2 nd plot = use hist command with bin size = 5 on finalscore 3 rd plot = use bar command to compare the midterm and final score distribution 10
11
P LOTTING 3D: L AB 7 Lab 7 Create vector using the following command >> x = 0:pi/50:2*pi >> y = 0:pi/50:2*pi >> z = sin(x’)* sin(y); Plot graph using meshz, mesh, surf, and waterfall 11
12
U SEFUL C OMMAND FOR RESEARCH Exporting the Figure print –djpeg figurename print –deps figurename print –depsc figurename Clustering: kmeans, linkage, cluster, clusterdata, pdist Fuzzy Logic: Fuzzy Logic Toolbox >>help fuzzy Nuerual Network Toolbox 12
13
D ATA M ANIPULATION : L AB 8: H OMEWORK Yodying conducts a research with undergrad students. One of her research tasks is to analyze the score of the undergrad students in Math 101 class. Since this is a mandatory class for all undergrad students, there are a total of 20 sections being offered per year. There are 30 students per section. Use Matlab to analyze the score that YodYing collected and put in the file “M101_12years.txt”. This is 12 years worth of data. Base on this score and given that the difficulty of the exam is at the same level every year, your job is to analyze the quality of the students. You may use any statistical methods to analyze the data. Submit Matlab code along with the graphs that help in supporting your answer. 13
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.