How to fixed the issue of variable data length ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 all
clc
x = -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 on
for i = 1:m-1
for 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 ),'.')
drawnow
zStore{i,j} = z(idx);
end
end
axis([-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)
0 Commenti
Risposta accettata
Walter Roberson
il 11 Ott 2020
Your x and y of the file are exchanged compared to your X and Y range.
You should probably be using
x = data(:,2) ; y = data(:,1) ; z = data(:,3 ) ;
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!