How to look up corresponding 2D matrix from a table of 8 columns?
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!