Interpolate pairs of values from matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chris Pruefert
am 3 Okt. 2024
Kommentiert: Mathieu NOE
am 11 Okt. 2024
I have a coarse 2D-matrix with [X,Y,Z]-values.
I want to input a Z-value and would like to interpolate possible values for the [X,Y]-pairs. These [X,Y]-pairs are then used for a fit. This means that for a given value of Z, if I choose any X value, Y can be calcualted and the other way arround.
I have tried the interp2 already, but it seems that I can only input X and Y values to get the interpolated Z value and not the other way around, where I input a Z-value and get a list of [X,Y]-pairs for that.
All the best
Chris
3 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 3 Okt. 2024
hello
you can surely get the required x , y data for a given z value ; use contour for that purpose as shown in code example below :
Z = peaks(50)/10;
level = 0.3;
surf(Z)
hold on
% extract all isoclines for a given level
[C,h] = contour(Z,level*[1 1]);
[m,n] = size(C);
ind = find(C(1,:)==level); % index of beginning of each isocline data in C
ind = [ind n+1]; % add end (+1)
for k = 1:numel(ind)-1
xc = C(1,ind(k)+1:ind(k+1)-1);
yc = C(2,ind(k)+1:ind(k+1)-1);
zc = level*ones(size(xc));
plot3(xc,yc,zc,'linewidth',5);
end
hold off
5 Kommentare
Weitere Antworten (0)
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!