tagtravel2.m

Revision 3 - 4/20/09 at 3:09 pm by brice.semmens

Previous revision
Back to revision history for tagtravel2.m
This file is part of the project TagTravel
function varargout = tagtravel2(varargin)
% TAGTRAVEL2 M-file for tagtravel2.fig
%      TAGTRAVEL2, by itself, creates a new TAGTRAVEL2 or raises the existing
%      singleton*.
%
%      H = TAGTRAVEL2 returns the handle to a new TAGTRAVEL2 or the handle to
%      the existing singleton*.
%
%      TAGTRAVEL2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TAGTRAVEL2.M with the given input arguments.
%
%      TAGTRAVEL2('Property','Value',...) creates a new TAGTRAVEL2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before tagtravel2_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to tagtravel2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help tagtravel2

% Last Modified by GUIDE v2.5 20-Nov-2008 13:26:24

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @tagtravel2_OpeningFcn, ...
                   'gui_OutputFcn',  @tagtravel2_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before tagtravel2 is made visible.
function tagtravel2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to tagtravel2 (see VARARGIN)

% Choose default command line output for tagtravel2
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes tagtravel2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = tagtravel2_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in giddyup.
function giddyup_Callback(hObject, eventdata, handles)
% hObject    handle to giddyup (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

handles.start=str2num(get(handles.start_date,'string'));
handles.d=str2num(get(handles.num_days,'string'));
handles.window=str2num(get(handles.win_size,'string'));
handles.t=str2num(get(handles.refresh,'string'));
handles.tst=str2num(get(handles.tstep,'string'));

try
if isnan(handles.start)
   msgbox('You have not entered a valid number into the start date field.','Oops...','error')
   return;
elseif mod(handles.start,1)~=0
    msgbox('Start date must be a round number. Start date will be rounded down.','Oops...','warn')
    handles.start = handles.start-mod(handles.iters,1); %ceilings to the nearest 1000
end

end
%enter more of this error catching stuff later...

%__________________________________________________________________________
%%READ THESE IN...
%but first check to make sure they exist

if exist('moondat.txt','file')==0
    msgbox('The file "moondate.txt" is missing from the MixSIR directory!')
    return;
else
    load moondat.txt;    %creates a matrix called moondat   
end
if exist('tagdat.txt','file')==0
    msgbox('The file "tagdat.txt" is missing from the MixSIR directory!')
    return;
else
    load tagdat.txt; data=tagdat;		%creates a matrix called tagdat
end
if handles.draw_map == 1
        if exist('map.txt','file')==0
            msgbox('The file "map.txt" is missing from the MixSIR directory!')
        return;
        else
            load map.txt;    %creates a matrix called coast
            coast=map;
        end
end
%__________________________________________________________________________
% NOW PUT THE DATA INTO THE CORRECT FORMAT FOR WORK...

data = sortrows(data,4); %sort the data based on time

% pull a subset of data for processing based on the start date and the
% number of days to run based on user input
data = data(find(data(:,4)>handles.start & data(:,4)floor(min(data(:,4)))-10 & moondat(:,1)tvec(i-handles.window) & data(:,4)1 %make an arrow end for each movement
                %this draws a tiny line back along the path so that only
                %the arrow head shows. To do this, I first needed to calc
                %the slope of the line.
                steps = size(plt,1);
                slope = (plt(steps,2) - plt(steps-1,2)) /(plt(steps,1) - plt(steps-1,1)); %rise over run.
                if plt(steps,1) < plt(steps-1,1)
                    arrow([plt(steps,1)+.000001,plt(steps,2)+slope*.000001],[plt(steps,1),plt(steps,2)],'FaceColor','r','Length',20);
                else
                    arrow([plt(steps,1)-.000001,plt(steps,2)+slope*-.000001],[plt(steps,1),plt(steps,2)],'FaceColor','r','Length',20);    
                end
            end
            %END ARROWHEADS----------------------------------------------------
  
        end
        
    end
        %MAKE DAY AND NIGHTS----------------------------------------------------
    %gray shading to axis area based on daylight
    if mod(tvec(i),1) < (5/24) || mod(tvec(i),1) > (22/24)
        whitebg(gcf,[.8,.8,.8]); %night hours are between 10pm and 5am
    elseif mod(tvec(i),1) < (7/24) || mod(tvec(i),1) > (21/24)
        whitebg(gcf,[.9,.9,.9]); %dusk hours are 8-10pm and 5-7am
    else
        whitebg(gcf,[1,1,1]); %daylight the rest of the time
    end
    %END DAYS ANDNIGHTS----------------------------------------------------
    
    set(handles.date_text,'String',datestr(tvec(i))); %puts the date and hour on the plot
    M(1)=getframe; %for now, this just refreshs screen
    while toc
Sculpin 0.2 | xhtml | problems or comments? | report bugs