How to interpolate 2D array from 3D array?
이전 댓글 표시
A=[3 4 5 6 7];
numel(X)=23;
numel(Y)=42;
There are 5 different contour data with respect to X and Y like the one belove. I have 5 different contour data of 23x42, together a 3D array of 5x23x42. There are data for the given values of A, but l need data for interpolated values of A, for example in the case of A=4.7. Then l'll plot the data corresponding to the calculated value of A.
Thanks for your help!
댓글 수: 4
Mohammed
2023년 12월 15일
A = [3 4 5 6 7]; X and Y coordinate arrays that contain: numel(X) = 23 (so 23 X values) numel(Y) = 42 (so 42 Y values)
You have 5 different contour datasets that are 23x42 matrices, corresponding to the different X and Y coordinate values. So altogether you have a 3D array of size 5x23x42 containing this contour data.
Your current data is at the values of A given in your array, such as A=3, A=4, A=5, etc.
But what you want is to interpolate to calculate the contour data at intermediate A values like A=4.7.
So the process would be:
- Interpolate the 5x23x42 contour data to calculate an estimated contour dataset at A=4.7
- Plot the interpolated contour data corresponding to A=4.7 along with the X and Y coordinate data.
piston_pim_offset
2023년 12월 15일
I don't completely understand your question.
You have contour data on an x/y/z grid of size 5x23x42 and you have a value in between the 5 x-coordinates and you want to interpolate your 5x23x42 contour data to this value to get back a 23x42 matrix ?
piston_pim_offset
2023년 12월 15일
답변 (3개)
piston_pim_offset
2023년 12월 15일
편집: piston_pim_offset
2023년 12월 15일
Dyuman Joshi
2023년 12월 15일
이동: Image Analyst
2023년 12월 29일
Try this. Though I have no idea if it does what you asked for or not.
contourData = randn(5, 23, 42);
A = [3 4 5 6 7];
interpContourData = interp1(A, contourData, 4.7);
[X, Y] = meshgrid(1:size(interpContourData, 2), 1:size(interpContourData, 3));
interpContourData = permute(interpContourData, [3 2 1]);
contourf(X, Y, squeeze(interpContourData), 20)
댓글 수: 1
piston_pim_offset
2023년 12월 18일
이동: Image Analyst
2023년 12월 29일
contourData = randn(5, 23, 42);
x = 1:5;
y = 1:23;
z = 1:42;
X = [2.6 4.7];
contourData_interpolated = zeros(numel(X),23,42);
for j = 1:23
for k = 1:42
contourData_interpolated(:,j,k) = interp1(x,squeeze(contourData(:,j,k)),X);
end
end
카테고리
도움말 센터 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
