How to use linear interpolation to fill gaps to generate a contour (closed surface)

3 ビュー (過去 30 日間)
M = 0 0 0
0 0 3
0 3 3
3 3 3
0 0 0
0 0 3
3 0 0
0 0 0
% in the first colmn, btween 4th & 7th rows, i wan to fill 3. in the last column, between 4th and 6th i want to fill 3.
X = ~all(M==0,2)
N = interp1(find(X),M(X,:), 'nearest')
% its not giving me solution.
i am focusing only first and last column to generate controur (closed surface )
Plz need some tips.
your cooperation is highly appreciated.
warm regards

採用された回答

madhan ravi
madhan ravi 2019 年 7 月 26 日
編集済み: madhan ravi 2019 年 7 月 26 日
"i am focusing only first and last column..."
M = [0 0 0;...
0 0 3;...
0 3 3;...
3 3 3;...
0 0 0;...
0 0 3;...
3 0 0;...
0 0 0];
Constant = 3; % example value
f = find(M(:,1));
fx = f .* [true;false(numel(f)-1,1)];
M(setdiff(nonzeros(fx):max(f),f),1) = Constant;
l = find(M(:,end));
lx = l .* [true;false(numel(l)-1,1)];
M(setdiff(nonzeros(lx):max(l),l),end) = Constant
  3 件のコメント
madhan ravi
madhan ravi 2019 年 7 月 26 日
編集済み: madhan ravi 2019 年 7 月 26 日
I seemed to have answered your original question "% in the first colmn, btween 4th & 7th rows, i wan to fill 3. in the last column, between 4th and 6th i want to fill 3....
i am focusing only first and last column to generate controur (closed surface )" . You would be better off posting a new question.
M.S. Khan
M.S. Khan 2019 年 7 月 27 日
Dear Dr. M. Ravi if I have matrix in this shape. M =[0 0 0; 2 2 3; 3 3 0; 0 0 0; 3 3 0; 2 2 3; 0 0 0; 3 3 2; 0 0 0; 3 3 3] How can I fill: 3 0 0 3 —> 3 3 3 3 3 0 3 0 2 —> 3 3 3 0 2 3 0 3 2 0 3 0 3 —> 3 3 3 2 0 3 3 3

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2019 年 7 月 26 日
This will be your function:
Also read about fillgaps.
  2 件のコメント
M.S. Khan
M.S. Khan 2019 年 7 月 26 日
Bro, i dont have NAN values, i have zeros. so how to apply because i already applied but its give me same M matrix
KSSV
KSSV 2019 年 7 月 26 日
Replace zeros with NaN's. Simple.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurfaces, Volumes, and Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by