Borrar filtros
Borrar filtros

how to make the matrix 4 by 4 with the value of 10

3 visualizaciones (últimos 30 días)
amina shafanejad
amina shafanejad el 16 de Mayo de 2015
Comentada: Stephen23 el 25 de Jun. de 2015
hello i want to make the matrix with the dimension of 4 by 4 and each element have the value of 10 can u help me with that?

Respuestas (2)

Stephen23
Stephen23 el 16 de Mayo de 2015
Editada: Stephen23 el 21 de Mayo de 2015
Method one:
A = 10 * ones(4)
Method two:
A(1:4,1:4) = 10
Method three:
A = 10 + zeros(4)
Method four:
A = repmat(10,4,4)
Method five:
A = [10,10,10,10;10,10,10,10;10,10,10,10;10,10,10,10]
Method six:
A(4,4) = 0;
A(:) = 10
Method seven:
A = bsxfun(@plus,[1,1,1,1],[9;9;9;9])
Method eight:
A = [10;10;10;10]*[1,1,1,1]
Method nine:
A = 10.^ones(4)
Method ten:
A = toeplitz([10,10,10,10],[10,10,10,10])
Method eleven:
A = round(real(ones(4)^2.660965))
Method twelve:
A = mod(10,zeros(4))
Method thirteen:
A = accumarray([1,1],10,[4,4],@sum,10)
  2 comentarios
Jan
Jan el 21 de Mayo de 2015
What about: 10 + zeros(4) ? ;-)
Stephen23
Stephen23 el 21 de Mayo de 2015
Editada: Stephen23 el 21 de Mayo de 2015
Already there as Method Three :)
I avoided 9+ones(4) though, for being basically the same thing.

Iniciar sesión para comentar.


Star Strider
Star Strider el 19 de Mayo de 2015
And still another possibility:
A = randi([10 10], 4, 4);
  3 comentarios
Star Strider
Star Strider el 21 de Mayo de 2015
Thank you!
Stephen23
Stephen23 el 25 de Jun. de 2015
That wins the inaugural "Best Misuse of a MATLAB Function Award".
My other favorite is this one:

Iniciar sesión para comentar.

Categorías

Más información sobre Animation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by