Hi,
I have a set of data to be interpolated for two files. I could use the code below when the second file (representing Y axis) has 11 columns.
However, when the second file (representing Y axis) has only two columns, it shows the following error:
Error using griddedInterpolant
The grid vectors must contain unique points.
Error in interp1 (line 151)
F = griddedInterpolant(X,V,method);
Error in File11 (line 18)
x2 (k,:) = interp1(y3, x3, A(:,i), 'linear');
clear; clc;
Folder = cd;
N=1;
x2 = zeros(N, 10);
for k = 1:N;
Driftt = sprintf('Drift%d.out', k);
Reactt = sprintf('React%d.out', k);
matDrift = importdata(fullfile(Folder, Driftt));
matReact = importdata(fullfile(Folder, Reactt));
x1= matDrift(:,2);
y1= -matReact(:,2);
[x3, ix] = unique(x1);
y3 = y1(ix);
A=dlmread('result_all.txt');
for i=1:size(A,2)
x2 (k,:) = interp1(y3, x3, A(:,i), 'linear');
temp=x2(k,:);
temp(isnan(temp))=0.05;
x2(k,:)=temp;
fid=fopen(['result_' num2str(i) '.txt'],'a');
fprintf(fid,'%f\n',x2(k,:));
fclose(fid);
end
end