Contents
Aaron Klapheck
% Read Excel file 21-Aug-08 clear, clc, home fprintf('The date and time: %s \n', datestr(now))
The date and time: 22-Aug-2008 13:19:26
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('TempProbe1'); % Interpret the time into a usful format. hr_set = 0; %The hour is 2pm wich is a single digit. **(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 K C 0 292 19 0 292 19 1 292 19 1 292 19 2 292 19 2 292 19 3 292 19 4 292 19 4 292 19 5 292 19 5 292 19 6 292 19 6 292 19 7 292 19 7 292 19 8 292 19 8 292 19 9 292 19 9 292 19 10 292 19 10 293 20 11 293 20 12 294 21 12 294 21 13 294 21 13 295 22 14 295 22 14 295 22 15 296 23 15 297 24 16 297 24 16 297 24 17 297 24 17 297 24 18 298 25 19 298 25 19 298 25 20 298 25 20 298 25 21 298 25 21 298 25 22 298 25 22 297 24 23 297 24 23 296 23 24 295 22 24 295 22 25 295 22 25 294 21 26 294 21 27 294 21 27 294 21 28 293 20 28 293 20 29 293 20 29 293 20 30 293 20 30 293 20 31 293 20 31 292 19 32 292 19 32 292 19 33 292 19 33 291 18 34 291 18 35 291 18 35 291 18 36 291 18 36 291 18 37 291 18 37 291 18 38 291 18 38 290 17 39 290 17 39 290 17 40 291 18 40 291 18 41 292 19 42 293 20 42 293 20 43 294 21 43 294 21 44 295 22 44 295 22 45 295 22 45 296 23 46 296 23 46 297 24 47 297 24 47 297 24 48 297 24 48 298 25 49 298 25 50 298 25 50 298 25 51 298 25 51 298 25 52 299 26 52 299 26 53 299 26 53 299 26
Plot the Data Given in the Excel File
% This module is designed to plot the time vs. temperature information. t = All_data(:,1); C = All_data(:,3); plot(t, C), xlabel(text1), ylabel(text3), grid, ... title('Graph of temprature (C) over time (sec)')