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

29 visualizaciones (últimos 30 días)
nty huy
nty huy el 26 de Sept. de 2019
Comentada: raghav el 24 de Feb. de 2024
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???

Respuestas (2)

James Tursa
James Tursa el 26 de Sept. de 2019
Editada: James Tursa el 26 de Sept. de 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.

raghav
raghav el 24 de Feb. de 2024
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 comentarios
Walter Roberson
Walter Roberson el 24 de Feb. de 2024
%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 el 24 de Feb. de 2024
Yes Sir ! That's too an alternative !

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by