source: issm/trunk-jpl/src/m/DataProcessing/CreateDataMatrix.m@ 12996

Last change on this file since 12996 was 1177, checked in by seroussi, 16 years ago

minor

File size: 2.6 KB
Line 
1function [Mvalue Mx My]=CreateDataMatrix(x_m,y_m,track_coord,track_values),
2%CREATEDATAMATRIX - Create a map with average values of map
3%
4% This routine creates a map with average values of tracks.
5% x_m1 and y_m1 are two vectors containing the coordinates of the matrix
6% trac_coord is an exp file containing the coordinates of the tracks (x and y)
7% trav_values is a vector with the values along the track coordinates
8%
9% Usage:
10% [Mvalue Mx My]=CreateDataMatrix(x_m,y_m,track_coord,track_values),
11%
12% Example:
13% [Mvalue Mx My]=CreateDataMatrix(x_m,y_m,'trackcoord.exp',thickness_track)
14%
15% See also: CREATEDATABOUNDARIES, TRACKSTOMATRIX
16
17%Read the points of the tracks
18stru=expread(track_coord,1);
19nods=stru.nods;
20xtracks=stru.x';
21ytracks=stru.y';
22
23%First check that the parameters are ok:
24if (size(track_values,1)~=nods) || (size(xtracks,2)~=nods) || (size(ytracks,2)~=nods),
25 error('CreateDataMatrix error message : track coordinates and track values must have the same size');
26end
27
28%Compute number of rows and columns
29numrow=size(y_m,1)-1;
30numcol=size(x_m,1)-1;
31
32%Remove useless points of the track
33points=find(track_values==0);
34track_values(points)=[];
35xtracks(points)=[];
36ytracks(points)=[];
37points=find(isnan(track_values));
38track_values(points)=[];
39xtracks(points)=[];
40ytracks(points)=[];
41points=find(track_values<0);
42track_values(points)=[];
43xtracks(points)=[];
44ytracks(points)=[];
45
46points=find(xtracks<x_m(1) | xtracks>x_m(end) | ytracks<y_m(1) | ytracks>y_m(end));
47track_values(points)=[];
48xtracks(points)=[];
49ytracks(points)=[];
50
51%initialize some matrices
52numpoints=zeros(numrow,numcol);
53value=zeros(numrow,numcol);
54coordx=zeros(numrow,numcol);
55coordy=zeros(numrow,numcol);
56
57%Loop over the points of the track
58nel=size(track_values,1);
59fprintf('%s',' track processing progress: 0.00 %');
60for i=1:nel;
61 if mod(i,1000)==0,
62 fprintf('\b\b\b\b\b\b\b')
63 fprintf('%5.2f%s',i/nel*100,' %');
64 end
65
66 x=xtracks(i);
67 y=ytracks(i);
68
69 %get indices for the matrix
70 indexx=max(find(x_m<x));
71 indexy=max(find(y_m<y));
72
73 %get weighing coefficient
74 val=track_values(i);
75
76 %update numoverlap and weights
77 numpoints(indexy,indexx)=numpoints(indexy,indexx)+1;
78 value(indexy,indexx)=value(indexy,indexx)+val;
79 coordx(indexy,indexx)=coordx(indexy,indexx)+x;
80 coordy(indexy,indexx)=coordy(indexy,indexx)+y;
81
82end
83if nel>1000,
84 fprintf('\b\b\b\b\b\b\b\b')
85 fprintf('%4.2f%s\n',100,' %');
86end
87
88%Change the values of numoverlap to 1 if 0 since we are going to devide by this matrix
89numpoints(find(~numpoints))=1;
90
91%Create the center of mass for coordiantes and values.
92Mvalue=value./numpoints;
93Mx=coordx./numpoints;
94My=coordy./numpoints;
Note: See TracBrowser for help on using the repository browser.