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