필터 지우기
필터 지우기

How to create a matrix with the same number in every few rows?

조회 수: 11 (최근 30일)
Rebeca Miyar
Rebeca Miyar 2018년 8월 13일
댓글: Godwin 2022년 9월 19일
I need to create a matrix that's 250X250. Also, I need to have the same number in every 50 rows, something like this:
111
111
222
222
333
333
How can I do that? Thank you!

답변 (1개)

Magdy Saleh
Magdy Saleh 2018년 8월 13일
Create a 250 by 250 matrix:
A = zeros(250)
And then to fill any 50 rows with a particular number:
A(1:50,:) = 1
This will fill rows 1 to 50 with the number 1. You can do this for any number then to complete your task. Hope this helps
  댓글 수: 1
Godwin
Godwin 2022년 9월 19일
I have a similar problem also. I need a 256x256 matrix where the first row is 1 and the second is 2 all the way to 256. 1 1 1....1 2 2 2....2 . . . 256 256 256.....256. Like this. Can you help me?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by