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 Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by