Make a diamond - MATLAB Cody - MATLAB Central

Problem 1078. Make a diamond

Difficulty:Rate

Given n, odd number > 1, return n by n matrix consist of "null" and "*" characters arranged like a diamond.

No toolbox functions please.

n = 3

m =

 *
* *
 *

n = 7

m =

   *   
  * *  
 *   *  
*     *
 *   *  
  * *
   *

Solution Stats

30.11% Correct | 69.89% Incorrect
Last Solution submitted on Jun 05, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers91

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

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

Start Hunting!