% Sample code 22 Jan 2010, Professor Guth for SO503 % must open the first file with File, Import data % Matlab does not like ASCII text for values in the file (after header row) % Either remove the offending column before importing, or % convert the Text to a number with a global search and replace % create a vector from each column of the data %allocate storage for variables, and zero out the vectors Hours=zeros(6051,1); dx=zeros(6050,1); dy=zeros(6050,1); heading=zeros(6050,1); tc=zeros(6050,1); speed=zeros(6050,1); filhead=zeros(6050,1); for i=1:6051, %don't have time to get the hours right, will come back and fix Hours(i) = 10 + i/3600; end; for i=1:6050, dx(i)=X_MERC(i+1)-X_MERC(i); dy(i)=Y_MERC(i+1)-Y_MERC(i); tc(i)=(Hours(i+1)+Hours(i))/2; heading(i)=atan2(dy(i),dx(i)); heading(i)=rad2deg(heading(i)); if heading(i) < 0, heading(i) = heading(i) + 360; else %no need here, we think end end; filsize=13 filhead=filter(ones(1,filsize)/filsize,1,heading); f1=plot(tc,heading,tc,filhead); xlabel('Time (hours)');