Fill area inside 4 connected lines in a plot

I have a figure, similar to a rectangle. It consists of 4 lines. Top and bottom line is just a connection of the two bottom points, respectively two top points. But left and right line is a matrix with x and y values, resulting from a curve fit between the left top and bottom point, same for the right side. Now i want a matrix to be filled with zeros outside of the rectangles coordinates and with ones inside the rectangle (see picture below).

1 件のコメント

Stefan Lang
Stefan Lang 2020 年 10 月 5 日
Anybody has got an idea? Please

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

 採用された回答

KSSV
KSSV 2020 年 10 月 5 日

0 投票

Read about padzeros, padarrays.
A = ones(5,4) ;
iwant = zeros(8) ;
iwant(3:7,3:6) = A ;

3 件のコメント

Stefan Lang
Stefan Lang 2020 年 10 月 5 日
I don't think that's what im looking for. I have a 4 functions, as a matrix with x and y values. Now i want to combine these 4 functions/lines to a rectangle, then overlay a matrix and fill everything inside the rectangle in the matrix with ones, everything outside with zeros.
KSSV
KSSV 2020 年 10 月 5 日
[X,Y] = meshgrid(1:10,1:10) ;
[Xi,Yi] = meshgrid(linspace(1.5,9.5,9)) ;
plot(X,Y,'r',X',Y','r')
val = [1:numel(Xi)]' ;
text(Xi(:),Yi(:),num2str(val))
Stefan Lang
Stefan Lang 2020 年 10 月 12 日
I found the poly2mask(). That does exactly what i need. But thanks anyways.

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2020 年 10 月 2 日

コメント済み:

2020 年 10 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by