Create array Arr with 5 rows and 4 columns with each element = 5

조회 수: 27 (최근 30일)
nty huy
nty huy 2019년 9월 26일
댓글: raghav 2024년 2월 24일
vArr = [ 5 6 7 8; 2 3 4 5 ; 2 3 4 5; 2 3 4 5; 2 3 4 5 ]
but what does it mean with each element = 5 all number has to be 5???

답변 (2개)

James Tursa
James Tursa 2019년 9월 26일
편집: James Tursa 2019년 9월 26일
Yes. Replace all of your numbers with 5 and you will have it. E.g.,
Arr = [5 5 5 5; etc.
This is the hardest way to accomplish the result, but it does work.

raghav
raghav 2024년 2월 24일
CODE TO CREATE ARRAY OF ALL ELEMENTS OF 5 WITH 5 ROWS AND 4 COLUMNS
Arr=5*ones(5,4)
Arr = 5×4
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 2월 24일
%alternate alternate
Arr = repmat(5, 5, 4)
Arr = 5×4
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
raghav
raghav 2024년 2월 24일
Yes Sir ! That's too an alternative !

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by