필터 지우기
필터 지우기

perform interpolation each row of a matrix

조회 수: 5 (최근 30일)
wangm
wangm 2023년 2월 3일
댓글: Fangjun Jiang 2023년 2월 3일
i have a matrix A with one million rows, and each row is monotonic increase. the value in each row is x.
The interpolation is perform to obtain one million yi for each row given a constant xi value (xi is the same for each row) and given an array y (y is also the same for each row). is there an efficient way to get yi other than using loop.
right now i have to use loop like this:
for i = 1:1e6
yi(i) = interpi(A(i,:), y, xi);
end

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2023년 2월 3일
편집: Fangjun Jiang 2023년 2월 3일
You can use interp1() directly for this without for-loop.
x=1:10;
A=(1:10)'+(1:10);
xi=5;
y=interp1(x,A',xi)
y = 1×10
6 7 8 9 10 11 12 13 14 15
  댓글 수: 5
wangm
wangm 2023년 2월 3일
wait, you did not answer my question. in my question, matrix A is x, but you matrix A is y.
Fangjun Jiang
Fangjun Jiang 2023년 2월 3일
I was taking some guesses on your question. Now you need to clarify these. "the value in each row is x", "in my question, matrix A is x", "but you matrix A is y".
The best way is to provide a complete numerical example, including the value for x, xi, y.
You don't need to provide one million rows. Three row is sufficient.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2011b

Community Treasure Hunt

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

Start Hunting!

Translated by