Hi everyone,
May somone help me …
Might be my problem is very puzzling… I have same type of data in two diffrent files with varying data length. I code works perfectly for one data set (A .. Attched here) but did not work for the second data set (B attched here) without any error …
Code is as below:
clear allclcx = -130.04:0.0025:-129.96; y = 45.91:0.0025:45.99; n = length(x ) ;m = length(y ) ;[X,Y] = meshgrid(x,y ) ;data = load('B.txt');x = data(:,1) ; y = data(:,2) ; z = data(:,3 ) ;% plot grid
plot(X,Y,'r',X',Y','r ')hold onfor i = 1:m-1for j = 1:n-1% Get the points of each grid
P = [X(i,j) Y(i,j ) ;X(i,j+1) Y(i,j+1 ) ;X(i+1,j+1) Y(i+1,j+1 ) ;X(i+1,j) Y(i+1,j )] ;idx = inpolygon(x,y,P(:,1),P(:,2 )) ;iwant = [ z(idx )] ;plot(x(idx),y(idx ),'.')drawnowzStore{i,j} = z(idx);endendaxis([-130.04 -129.96 45.91 45.99])%
N = max(cellfun(@numel,zStore)); zMat = nan(10000,256);% for i = 1:numel(zStore)
k=1;for i = 1:32 for j=1:32 zMat(1:numel(zStore{i,j}),k) = zStore{i,j}; k=k+1; end end %xlswrite('data',zMat)
Best Answer