Drawing something simple with MATLAB

I need to write a code to produce the following pattern:
X...X
.X.X.
..X..
.X.X.
X...X
can anyone please help me with the code?

1 件のコメント

Enis
Enis 2011 年 10 月 27 日
Actually, it has to be like this for any value of R specified, diagonals are X-es, the rest is dots. I got in a really simple way.

回答 (3 件)

Ajay Kumar
Ajay Kumar 2011 年 10 月 27 日

0 投票

disp(' ')
disp('X...X')
disp('.X.X.')
disp('..X..')
disp('.X.X.')
disp('X...X')
disp(' ')
Ajay Kumar
Ajay Kumar 2011 年 10 月 27 日

0 投票

Try the above. It should work. This is the simplest if you are just trying to display characters
Walter Roberson
Walter Roberson 2011 年 10 月 27 日

0 投票

Hint to get you started:
flipud(diag('XXXXX'))

この質問は閉じられています。

質問済み:

2011 年 10 月 27 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by