getdata.m

Revision 1 - 5/31/07 at 3:40 pm by e2holmes

Back to revision history for getdata.m
This file is part of the project Teaching code for State-space models
function [data, dataname, datatype] = getdata(varargin);
%to spec just ask for data getdata()
%to spec get data based on a given dataype spec inline: getdata(datatype)
%to spec get x yrs of data: getdata(-99,x) (ask user for datatype), getdata(datatype,x) (spec datatype inline)

%Give data based on code
maxtype = 8; %be nice if user inputs a code that's not here
data = [];

%if user didn't input any info then ask for datatype
if(nargin == 0) datatype = -99; 
else datatype = varargin{1};
end

while(datatype == -99) %no good datatype entered
   datatype = input('Data code: (input 0 to see options): ');

	if(~ismember(datatype,1:maxtype) ) 
      display(...
         {'options:';...
            '1 Grey-headed albatross (beach carcass counts)';...
            '2 Trumpeter Swan; US (petitioned)';...
            '3 White-capped albatross (beach carcass counts)';...
            '4 Northern fur seal (bull count)';...
            '5 Sharp-tailed grouse, WA';...
            '6 Mute swan, Thames';...
            '7 Wolves, Isle Royal Park';...
            '8 Northern fur seal (bull count); shortened'...
         }); 
   	datatype = -99;
   end
end

%if ans = 1 use Grey-headed Albatross Caracass Beach Patrols; Ornithological Society of New Zealand
if(datatype == 1) 
   data = [13.37	19.14	13.81	18.25	3.79	6.95	21.17	39.47	42.39	3.10	12.21	8.09	8.80 11.81	14.02	7.92	9.34	8.38	11.58	8.47	9.89	1.18	5.78	7.59	2.82	3.71	4.94	2.50	4.32	5.41	3.15	7.43	3.41	1.62	2.90];
   dataname = 'Grey-headed albatross (beach carcass counts)';
end

%if ans ~= 1 use Trumpeter Swans, US
if(datatype == 2) 
   data = [572	-99	-99	581	-99	-99	544	-99	-99	582	-99	-99	547	563	575	452	611	659	598	626	555	563	354	454	427	458	427	469	417	481	487	371	417];
   dataname = 'Trumpeter swan; US';
end

if(datatype == 3) 
   data = [31.56	11.24	13.81	5.65	6.73	12.83	3.90	9.03	2.90	3.10	6.11	2.38	12.32	8.05	12.98	10.78	5.12	3.91	7.92	10.40	9.47	5.12	4.82	4.93	8.06	9.00	8.39	8.51	8.11	11.80	11.25	9.29	15.12	2.70	11.11];
   dataname = 'White-capped albatross (beach carcass counts)';
end

if(datatype == 4) 
   data = [5226	5182	5332	4992	3961	3478	3030	2991	2914	3031	2146	2754	1785	583	1281	1343	2347	2130	2534	2879	3771	3479	3275	2914	-99	3064	3026	2951	2660	2517	2465	2651	2071	2934	2647	2803	2296	2200	2526	2274	2074	2171	2439	2164	1874	1665];
   dataname = 'Northern fur seal (bull count), St. George Island, AK';
end

if(datatype == 5) 
   data = [10672	8894	7412	6029	6235	6500	4824	3676	4471	5176	2412	3029	3500	3059	3000	2353	1971	1412	1324	1324	1559	1500	1529	1324	853	735	765	941	824	765];
   dataname = 'Sharp-tailed grouse, WA';
end

if(datatype == 6) 
   data = [506	435	495	433	517	503	584	535	453	460	500	559	529	-99	642	657	589	516	563	668	708	796	601	677	522	564	597	527	555	529	578	496	429	516	522	577	546	410	510	420	449	397	390	372	417	418	358	348	289	356	356	361	378	378	426	381	409	387	488	526	577	582	475	493	419	296	422	363	378	389	423	466	460	475	469	490	478	448	474	482	474	377	421	384	435	495	545	636	543	581	623	523	595	620	583	613	661	656	597	661	717	587];
   dataname = 'Mute Swan, Thames';
end

if(datatype == 7) 
   data = [20	23	24	31	41	44	34	40	43	50	30	14	23	24	22	20	16	12	12	15	12	12	13	17	17];
   dataname = 'Wolves, Isle Royal Park';
end

if(datatype == 8) 
   data = [3771	3479	3275	2914	-99	3064	3026	2951	2660	2517	2465	2651	2071	2934	2647	2803	2296	2200	2526	2274	2074	2171	2439	2164	1874	1665];
   dataname = 'Northern fur seal (bull count), same as 4 but shortened';
end

if(nargin == 2) %number of years to use
   data = data((end-varargin{2}+1):end);
end

datainfo.data = data;
datainfo.name = dataname;
datainfo.type = datatype;
disp(dataname);
Sculpin 0.2 | xhtml | problems or comments? | report bugs