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

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???

Antworten (2)

James Tursa
James Tursa am 26 Sep. 2019
Bearbeitet: James Tursa am 26 Sep. 2019
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.
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 Kommentare

%alternate
Arr = 5 + zeros(5,4)
Arr = 5x4
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
%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
Yes Sir ! That's too an alternative !

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 26 Sep. 2019

Kommentiert:

am 24 Feb. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by