Create an n-by-n null matrix and fill with ones certain positions - MATLAB Cody - MATLAB Central

Problem 1430. Create an n-by-n null matrix and fill with ones certain positions

Difficulty:Rate

The positions will be indicated by a z-by-2 matrix. Each row in this z-by-2 matrix will have the row and column in which a 1 has to be placed.

Example:

n=3;

mat=[1 3; 2 1]; --> We want A(1,3)=1 and A(2,1)=1

A = FillWithOnes(n,mat);

A=[0 0 1; 1 0 0; 0 0 0];

Solution Stats

50.33% Correct | 49.67% Incorrect
Last Solution submitted on Mar 11, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers631

Suggested Problems

More from this Author9

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page