How to change sampling points and frequency of a matrix?

조회 수: 1 (최근 30일)
Mirlan Karimov
Mirlan Karimov 2020년 6월 13일
댓글: Mirlan Karimov 2020년 6월 16일
I have a m x n grid X and another m x n matrix v with values corresponding to each grid point of X . I want:
1) resample X to make it m x m without changing the boundary values (i.e. max and min)
2) the interp v according to the new grid so that it is also m x m

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 14일
Try something like this
m = 10;
n = 15;
x_range = [0 1];
y_range = [3 6];
[X, Y] = meshgrid(linspace(x_range(1), x_range(2), n), linspace(y_range(1), y_range(2), m));
Z = rand(size(X));
[X_new, Y_new] = meshgrid(linspace(x_range(1), x_range(2), m), linspace(y_range(1), y_range(2), m));
Z_new = interp2(X, Y, Z, X_new, Y_new);
X, Y, and Z old grid points having dimensions of m*n. X_new, Y_new, and Z_new and new grids of dimension m*m.
  댓글 수: 1
Mirlan Karimov
Mirlan Karimov 2020년 6월 16일
That was exactly what I had written but I had made a mistake way before this part, I later realized. Anyway, thank you for your answer. I will accept it as it is correct.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by