sparse_matrix - MATLAB Cody - MATLAB Central

Problem 42697. sparse_matrix

Difficulty:Rate

You convert a vector to a sparse matrix.

for example x =[1 2 3];

output will be y =

             [1 0 0
              0 1 0
              0 0 1];

Solution Stats

67.57% Correct | 32.43% Incorrect
Last Solution submitted on Nov 15, 2025

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...

Problem Recent Solvers46

Suggested Problems

More from this Author21

Problem Tags

Community Treasure Hunt

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

Start Hunting!