Home > atmlab > geographical > test_generate_data_sin_cos.m

test_generate_data_sin_cos

PURPOSE ^

% test_generate_data_sin_cos

SYNOPSIS ^

function [gridded,ungridded] = test_generate_data_sin_cos(sz)

DESCRIPTION ^

% test_generate_data_sin_cos
 GENERATES DATA gridded and ungridded in a sin cos pattern

 IN 
         sz            the resolution of the data



 OUT 
        gridded       structure containing gridded data (data,lat,lat)
        ungridded     structure containing ungridded data (data,lat,lat)



  USAGE 
        [gridded,ungridded] = test_generate_data_sin_cos(sizeGrid)


  Created by Salomon Eliasson

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

test_generate_data_sin_cos.m

SOURCE CODE ^

0001 function [gridded,ungridded] = test_generate_data_sin_cos(sz)
0002 %% test_generate_data_sin_cos
0003 % GENERATES DATA gridded and ungridded in a sin cos pattern
0004 %
0005 % IN
0006 %         sz            the resolution of the data
0007 %
0008 %
0009 %
0010 % OUT
0011 %        gridded       structure containing gridded data (data,lat,lat)
0012 %        ungridded     structure containing ungridded data (data,lat,lat)
0013 %
0014 %
0015 %
0016 %  USAGE
0017 %        [gridded,ungridded] = test_generate_data_sin_cos(sizeGrid)
0018 %
0019 %
0020 %  Created by Salomon Eliasson
0021 
0022 if ~exist('sz','var')
0023     sz = 1;
0024 end
0025 
0026 gridded.lat    = -90+sz/2:sz:90-sz/2;
0027 gridded.lon    = -180+sz/2:sz:180-sz/2;
0028 gridded.data   = zeros(length(gridded.lat),length(gridded.lon));
0029 ungridded.data = zeros(length(gridded.lat)*length(gridded.lon),1);
0030 ungridded.lon  = zeros(size(ungridded.data));
0031 ungridded.lat  = zeros(size(ungridded.data));
0032 
0033 ln = length(gridded.lon);
0034 lt = length(gridded.lat);
0035 ug=1;
0036 for j=0:lt-1
0037     for i=0:ln-1
0038 
0039         gridded.data(j+1,i+1)=sin(((i+lt)/ln)*pi+pi/2)* cos((j/lt)*pi+pi/2)*100+160;
0040         
0041         if nargout==2
0042             ungridded.data(ug) = gridded.data(j+1,i+1);
0043             ungridded.lat(ug)  = j - 90;
0044             ungridded.lon(ug)  = i - 180;
0045             ug = ug+1;
0046         end
0047     end
0048 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005