How can I use interp1 to interpolate the last row of a matrix?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have the following 4 x 3 matrix:
A = [1,2,3;4,5,6;7,8,9;10,11,12]
I want to interpolate the rows of this matrix and get a 5 x 3 matrix to just get a single, last interpolated row. I am not sure how to use interp1 to this end. Can someone please help? Thank you!
댓글 수: 0
채택된 답변
Voss
2022년 12월 17일
Here's my guess at what you mean:
A = [1,2,3;4,5,6;7,8,9;10,11,12]
N = size(A,1);
A(N+1,:) = interp1(1:N,A,N+1,'linear','extrap')
댓글 수: 0
추가 답변 (1개)
Bora Eryilmaz
2022년 12월 17일
편집: Bora Eryilmaz
2022년 12월 17일
Interpolation is probably not the right term here since interpolation, typically, requires a set of (x,y) data and a different set of x values to use for finding interpolated y values.
A simple approach could be to use the column means of the A matrix to find the row of average values:
A = [1,2,3;4,5,6;7,8,9;10,11,12]
A(end+1,:) = mean(A)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation of 2-D Selections in 3-D Grids에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!