Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

matlab/mparam.m

Go to the documentation of this file.
00001 function [ssMean,alpha,beta] = mparam(time, encData, ssStartTime, ssStopTime)
00002 % determine truck motor parameters from encoder data
00003 %
00004 %[ss_velocity,alpha] = mparam(time, encData, ssStart, ssStop)
00005 % encData  = (N x 1) array with cumlative encoder data 
00006 %            (use sum(encData')') to create
00007 % ssStart  = array index where steady state operation begins (1 to len)
00008 % ssStop   = arrry index where steady state operation ends (1 to len)
00009 
00010 len = length(encData);
00011 encDot = zeros(len,1);
00012 encDot(2:len) = encData(2:len) - encData(1:len-1);
00013 %time = [1:len];
00014 
00015 % convert time into an array index
00016 ssStart = interp1(time,[1:len],ssStartTime);
00017 ssStop = interp1(time,[1:len],ssStopTime);
00018 
00019 % make plot of differential encoder values, and ss value
00020 figure(1);
00021 hold off;
00022 plot(time,encDot,'r');
00023 hold on;
00024 
00025 % determine steady state averages velocity
00026 ssMean = mean(encDot(ssStart:ssStop))
00027 
00028 % plot steady state value over given range
00029 plot([ssStartTime,ssStopTime],[ssMean,ssMean],'b');
00030 legend('differential encoder value', 'ss mean value and range');
00031 
00032 
00033 % make plot of linearized exponential data from beging of data
00034 % to when steady state "starts" 
00035 % the problem is when we get close to the the steady state value, 
00036 % noise is amplified
00037 figure(2);
00038 linearizedEncDot = real(log(ssMean-encDot));
00039 hold off;
00040 plot(time([1:ssStart]), linearizedEncDot(1:ssStart),'r');
00041 hold on;
00042 
00043 % determine the coefficents for the linear regession
00044 p = polyfit(time(1:ssStart),linearizedEncDot(1:ssStart),1);
00045 linData = p(1) * time([1:ssStart]) + p(2);
00046 plot(time([1:ssStart]),linData,'b');
00047 
00048 legend('log(encDot - ssMean)', 'linear regresion');
00049 
00050 
00051 % create normal plot of data from input data
00052 figure(3);
00053 hold off;
00054 plot(time,encDot,'r');
00055 hold on;
00056 expData = ssMean - exp(p(2)) * exp( time * p(1) );
00057 plot(time,expData,'b');
00058 
00059 alpha = p(1)
00060 beta = exp(p(2))
00061 

Generated on Fri Sep 1 14:25:49 2006 for Raptor by  doxygen 1.4.4