Contents
Aaron Klapheck
% Read Excel file 22-Aug-08 clear, clc, home fprintf('The date and time: %s \n', datestr(now))
The date and time: 22-Aug-2008 13:33:45
Program Information
% Purpose % The purpose of this program is to take information from a Parallax Basic % Stamp, by way of the StampDAQ program, and analyze it using MATLAB. This % program is especially designed to interpret the Time data sent by the % Basic Stamp. % Execution % How this works is that information from the Basic Stamp can be saved in % an Excel document which can be read by MATLAB. This program is especially % designed to work as a kind of data acquisition (DAQ) interface. Sensor % data from the Basic Stamp can be sent to the StampDAQ program by either % being saved in the EEPROM on the Basic Stamp and then "dumping" the % information into StampDAQ all at once or by sending this information % to StampDAQ as it is being recorded by the Basic Stamp. This program % is designed to work exclusively on the latter. The reason this program % works especially for the latter is because as information is being sent % to StampDAQ the time can be accurately recorded as to when each % measurement was taken place, whereas if we do a data dump then there is % no way we can figure out when the measurement(s) was taken. Once the % sensor information is in StampDAQ then this program is designed to % analyze, interpret, and put this data into a more meaningful form. % Users % For those who wish to use this code for their own data measurements the % following information may prove useful. The parts of this code that would % change depending on the information that one is trying to interpret are % followed by a marking; marking: **(may need to change)**.
Read the Excel File
% Read the xls file that contains the data and store the numerical and % non-numerical parts in data and text respectively [data, text] = xlsread('PhotoSensor1'); % Interpret the time into a usful format. hr_set = 1; %The hour is 12pm which is two digits. **(may need to change)** rows = 101; %The number of data points taken. **(may need to change)** [time] = StampDAQtimeConverter(rows, text, hr_set);
Error Checking
% The following gives the dimensions of the two matrices in question % namely data and time. The matrix "data" stores all of the sensor % measurements. The matrix "time" stores all of the time measurements. The % dimensions are given in terms of row x columns. This information is given % because a possible error is to have the number of rows for both matrices % not line up exactly. The row data given should match the row data % entered in the previous section. fprintf('\nThe size of time = %4.0f x %1.0f \n', size(time)) fprintf('The size of data = %4.0f x %1.0f \n \n', size(data)) % The following lines are used so that the fprintf commands will work. All_data = [time,data]; text1 = cell2mat(text(1,1)); %Stores name for type of sensor data stored text2 = cell2mat(text(1,2)); %Stores name for type of sensor data stored text3 = cell2mat(text(1,3)); %Stores name for type of sensor data stored % **(may need to change, add or delete text#)** % These two lines are used to display all the data and labels each data % column. The number of data columns depends on number of each type of % measurement used. fprintf('%s \t %s \t %s\n', text1, text2, text3) %**(may need to change)** fprintf('%4.0f \t %3.0f \t %3.0f \n', All_data') %**(may need to change)**
The size of time = 101 x 1 The size of data = 101 x 2 Time PRRight PRLeft 0 72 69 1 72 69 1 72 69 2 72 69 2 71 69 3 63 65 3 55 60 4 35 57 4 23 54 5 15 36 5 15 30 6 12 28 6 13 22 7 23 21 8 50 19 8 54 48 9 59 57 9 62 61 10 64 62 10 62 60 11 60 59 11 58 55 12 56 49 12 53 28 13 50 18 13 45 17 14 15 19 15 11 21 15 12 30 16 12 39 16 18 49 17 43 53 17 49 58 18 53 61 18 48 58 19 45 56 19 42 54 20 40 52 20 28 50 21 21 49 21 14 47 22 11 37 23 10 32 23 15 28 24 29 20 24 41 16 25 43 15 25 45 15 26 49 20 26 53 46 27 56 52 27 57 53 28 58 55 28 59 57 29 59 56 30 57 35 30 55 23 31 54 22 31 53 20 32 50 17 32 47 15 33 44 13 33 42 12 34 39 9 34 36 8 35 34 6 35 34 5 36 32 4 36 33 3 37 37 3 38 38 2 38 42 2 39 37 2 39 32 3 40 31 4 40 32 6 41 33 6 41 34 9 42 36 12 42 33 15 43 36 17 43 16 19 44 13 20 44 15 20 45 15 23 46 15 23 46 13 26 47 10 26 47 11 30 48 7 25 48 6 24 49 5 26 49 4 33 50 3 30 50 2 28 51 2 26 51 1 25 52 1 26 53 1 24 53 1 27 54 1 28
Plot the Right Photo Resister Data
% This module is designed to plot the time vs. temperature information. t = All_data(:,1); PRRight = 80 - All_data(:,2); plot(t, PRRight), xlabel(text1), ylabel(text2), grid, ... title('Rigth Photo Light Values (light intensity) Over Time (sec)')
Plot the Left Photo Resister Data
% This module is designed to plot the time vs. temperature information. PRLeft = 80 - All_data(:,3); plot(t, PRLeft), xlabel(text1), ylabel(text3), grid, ... title('Left Photo Light Values (light intensity) Over Time (sec)')