How to look up corresponding 2D matrix from a table of 8 columns?

조회 수: 1 (최근 30일)
Yun Inn
Yun Inn 2012년 7월 23일
I have 8 columns corresponding to thickness 0,5,10,15,20,25,30,35cm. Each column/thickness consist of one 2D matrix.
Columns 1 through 5
[1024x1024 double] [1024x1024 double] [1024x1024 double] [1024x1024 double] [1024x1024 double]
Columns 6 through 8
[1024x1024 double] [1024x1024 double] [1024x1024 double]
How do I get a corresponding 2D matrix for a known thickness, e.g.7cm?

답변 (1개)

Titus Edelhofer
Titus Edelhofer 2012년 7월 23일
Hi,
in this case probably this is easiest done by hand:
columns = 0:5:35;
thick = 7;
% find the 2 indices where 7 falls in between:
idx = find(columns<=thick, 1, 'last');
fraction = (thick-columns(idx)) / (columns(idx+1)-columns(idx));
% the interpolation matrix is the left one + a fraction of the difference:
matrix = allMatrices{idx} + fraction * (allMatrices{idx+1}-allMatrices{idx});
Note, you need to handle the cases thick<0 and thick>=35 with care.
Titus
  댓글 수: 2
Yun Inn
Yun Inn 2012년 7월 23일
Hi Titus
What do I do if thick is also a 2D matrix?
Titus Edelhofer
Titus Edelhofer 2012년 7월 23일
Hmm, with the original question/answer you get the 2D interpolation matrix for one thickness. If thick is a 2D matrix (say NxM), and you loop, you will get N*M interpolation matrices of size 1024x1024. If N and M are not too large, this is no problem.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by