How to repeat calculations at different large sets of coordinates.

3 views (last 30 days)
Hi there,
I'm very new to Matlab and working in for interpolation project. I couldn't get this figured out how to repeat the calculation for the estimates value of z for large sets of coordinates (about 100 coordinates) at one time. Currently I'm stuck at only solving one coordinate per time. Does anybody have any suggestions for how to do this? Thank you.
%import data from .txt file
Valuez=importdata('xyz.txt');
Coordinate=Valuez.data;
x=Coordinate(:,1);
y=Coordinate(:,2);
z=Coordinate(:,3);
%Create the matrix/vector of distances between the pairs of data points
xy = [x y];
[m n] = size(xy);
n = m;
D1 = zeros(m, n);
for i = 1 : m
for j = 1 : n
D1(i, j) = sqrt((xy(i, 1) - xy(j, 1)) ^ 2 + (xy(i, 2) - xy(j, 2)) ^ 2);
end
end
D1;
%Data covariance matrix using power variogram model (power=1.5)
K=D1.^(1.5);
%Coordinate input
x1=5;
y1=3;
%Create the vector of distances between data points with estimation points
xy1=[x1 y1];
D2=pdist2(xy,xy1);
k= D2.^(1.5);
%Solve
lambda1=K^-1 * k;
z1= lambda1.'*z;
z1

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 3 Sep 2019
Edited: KALYAN ACHARJYA on 3 Sep 2019
z1= lambda1.*z
Command Window:
>> z1
z1 =
-0.1666
0.5964
0.9796
0.0263
-0.3027
3.7607
Any issue?
  2 Comments
Zephyr
Zephyr on 3 Sep 2019
Currently I'm stuck at only solving one coordinate per time. Need to solve multiple coordinates at once. For example to find the value of z1,z2,z3.....,z100 at given coordinates (x1,y1),(x2,y2), (x3,y3)...,(x100,y100).
KALYAN ACHARJYA
KALYAN ACHARJYA on 3 Sep 2019
for l=1:100
z(l)= %Do calculation based on ......(x(l),y(l))
% Assuming z1, z2 are scalars
% If z1, z2 are vectors, use
z{l}= %Do calculation based on ......(x(l),y(l))
end

Sign in to comment.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!