interp2 error: The grid vectors must be strictly monotonically increasing.
36 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
The error is that "the grid vector must be strictly monotonically increasing" I am confused by this, because the vector a1 and b1 is absolutely monotonic.
%% plot segment1 int=1; % interval of mesh method='nearest'; s1x=Segment1new(:,3); s1y=Segment1new(:,4); s1z=Segment1new(:,5);
mins1x=ceil(min(s1x)); maxs1x=fix(max(s1x)); mins1y=ceil(min(s1y)); maxs1y=fix(max(s1y));
a1=(mins1x:int:maxs1x); b1=(mins1y:int:maxs1y);
[S1X,S1Y]=meshgrid(a1,b1); %produce mesh grid S1Z=interp2(s1x,s1y,s1z,S1X,S1Y,method);%interpolate ZZ mesh(S1X,S1Y,S1Z) hold on
0 Kommentare
Antworten (1)
Steven Lord
am 10 Mai 2017
The query points do not need to be strictly monotonically increasing. The points at which the data to be interpolated is specified do need to be strictly monotonically increasing.
% Generate sample data
[Xmono, Ymono] = meshgrid(-3:3, -3:3);
Xnon = Xmono(randperm(7), randperm(7));
Ynon = Ymono(randperm(7), randperm(7));
V = Xmono + Ymono;
% Interpolate using the monotonically increasing X and Y data as the first two inputs
Vq1Succeeds = interp2(Xmono, Ymono, V, Xnon, Ynon);
szVq1 = size(Vq1Succeeds)
% Interpolate using the non-monotonically increasing X and Y data as the first two inputs
Vq2Fails = interp2(Xnon, Ynon, V, Xmono, Ymono);
szVq2 = size(Vq2Fails)
To interpolate scattered data (data known at locations that don't lie on a grid) use scatteredInterpolant instead.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!