How to create a graph with a shaded area ?

4 ビュー (過去 30 日間)
Jesus
Jesus 2013 年 11 月 1 日
編集済み: Jesus 2013 年 11 月 4 日
how to create a graph with a shaded area (rectangle with diagonal lines) ? I would like to create a graph (in MATLAB) similar to this:

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 1 日
編集済み: Azzi Abdelmalek 2013 年 11 月 2 日
a=8; % Rectangle width
b=15; % Rectangle height
n=8; % Number of stripes is equal to 2*n
plot([0 a a 0 0],[0 0 b b 0],'k','linewidth',4)
set(gca,'xlim',[0 a*1.2],'ylim',[0 b*1.2]);
x11=[zeros(1,n) linspace(0,a,n);linspace(0,a,n) ones(1,n)*a]
y11=[linspace(0,b,n) b*ones(1,n);zeros(1,n) b-fliplr(linspace(0,b,n))]
hold on
plot(x11 ,y11,'k','linewidth',4)
  2 件のコメント
Jesus
Jesus 2013 年 11 月 2 日
Azzi Abdelmalek, thanks for the reply.
Jesus
Jesus 2013 年 11 月 4 日
編集済み: Jesus 2013 年 11 月 4 日
Now I'm trying to make a graph like this:
What I have to add the above code to generate this graph ? I tried several modicações in the above code, but could not make the graph.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by