close all
clear
clc
hold on
grid on
P_outside = ([0.1+0.6i,0.3+0.6i,0.4+0.8i,0.3+i,0+i,0+0.5i,0,0.1+0i,0.1+0.6i]);
P_inside = ([0.1+0.7i,0.21+0.7i,0.21+0.9i,0.1+0.9i,0.1+0.7i]);
plot(P_outside)
plot(P_inside)
xlim([-0.2,1])
ylim([-0.1,1])
I would like to fill the 'P' with a color, how do I do that?

 採用された回答

Dave B
Dave B 2021 年 11 月 4 日
編集済み: Dave B 2021 年 11 月 4 日

1 投票

You can use the fill function to fill a region. You can retrieve the x and y values using real and imag (I don't think fill does the same trick of splitting complex numbers like plot does)
P_outside = ([0.1+0.6i,0.3+0.6i,0.4+0.8i,0.3+i,0+i,0+0.5i,0,0.1+0i,0.1+0.6i]);
P_inside = ([0.1+0.7i,0.21+0.7i,0.21+0.9i,0.1+0.9i,0.1+0.7i]);
x=[real(P_outside) real(P_inside)];
y=[imag(P_outside) imag(P_inside)];
fill(x,y,'r','EdgeColor','none')
xlim([-0.2,1])
ylim([-0.1,1])

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

タグ

質問済み:

2021 年 11 月 4 日

編集済み:

2021 年 11 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by