2D Interpolation of data
Show older comments
Hi..I was trying to perform a 2D-interpolation for 2 data files. The file AOA0_u600 contains data of nodenumber, x-coordinate, y-coordinate, z-coordinate and pressure.
The file Y-600 contains data of entity id, x-coordinate, y-coordinate and z-coordinate. Both the files contain the data for the same Y-coordinate.
Basically the idea was to interpolate the value of pressure at the values of x and z coordinate (sample points of 1st file) to the values of x and z-coordinate (query points of the 2nd file)
However,when using the interp2 function to interpolate the values, i was recieving the following error
%Error using griddedInterpolant
The grid vectors must be strictly monotonically increasing.
%Error in interp2>makegriddedinterp (line 229)
F = griddedInterpolant(varargin{:});
%Error in interp2 (line 129)
F = makegriddedinterp({X, Y}, V, method,extrap);
Could anyone please guide me as to how to resolve this issue?
clear all;
clc;
fid=fopen('AOA0_u600.txt');
a=textscan(fid, '%f %f %f %f %f', 'HeaderLines', 1);
b=cell2mat(a);
c=sortrows(b,2);
x=c(:,2);
x=x+0.275;
y=c(:,4);
z=c(:,5);
fid =fopen('Y-600.txt');
A=textscan(fid, '%f %f %f %f', 'HeaderLines', 12);
B=cell2mat(A);
C=sortrows(B,2);
X=C(:,2);
X1=X/1000;
Y=C(:,4);
Y1=Y/1000;
D=interp2(x,y,z,X1,Y1);
Accepted Answer
More Answers (0)
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!