Interpolating contour plot using user input

조회 수: 34 (최근 30일)
Radhika Kulkarni
Radhika Kulkarni 2021년 1월 19일
댓글: piston_pim_offset 2023년 11월 18일
Hello,
I have created a 2D contour map using a 25x19 matrix and was wondering how to interpolate the value at certain user-input x-y coordinates? Essentially, I want the user to enter coordinates that are either integer or decimal, and for the code to output the value at that corresponding location. Any help would be appreciated :)
data = readmatrix('pixeltxt.txt');
contourf(data);
grid minor

채택된 답변

Bram Schroeders
Bram Schroeders 2021년 1월 20일
I think taking a look at this documentation may help you https://www.mathworks.com/help/matlab/ref/scatteredinterpolant.html
  댓글 수: 13
Bram Schroeders
Bram Schroeders 2021년 1월 26일
You can use the rescale function:
So for instance you have a vector called A and you want to set the x-axis to [-21.4 -19.6] and y-axis to [-17.5 -15] you can do this:
A(:,1) = rescale(A(:,1),-21.4,-19.6);
A(:,2) = rescale(A(:,2),-17.5,-15.0);
I think this is what you mean
piston_pim_offset
piston_pim_offset 2023년 11월 18일
Thanks for your answers Bram Schroeders

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by