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?

回答(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 个评论
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