creat matrix with specific row element

2 views (last 30 days)
Mohannad Almalki
Mohannad Almalki on 16 Oct 2020
Answered: KSSV on 16 Oct 2020
Create a matrix of 100 rows and 100 columns. The odd columns should contain values 2, and the even columns, values 0

Answers (1)

KSSV
KSSV on 16 Oct 2020
iwant = zeros(100) ;
iwant(:,1:2:end) = 2 ;

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!