creating a 8x8 matrix with only -1
121 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
i want to create a 8x8 matrix withn only the number -1 how do i do it?
0 comentarios
Respuestas (3)
Torsten
el 27 de Oct. de 2024 a las 23:19
Movida: Torsten
el 27 de Oct. de 2024 a las 23:19
Use "ones" to build a matrix of ones and multiply it by (-1).
1 comentario
Walter Roberson
el 28 de Oct. de 2024 a las 0:21
You have to be careful to build up the 8 x 8 size for the ones() call, out of pure -1's. It is certainly possible to do.
埃博拉酱
el 28 de Oct. de 2024 a las 13:46
Editada: 埃博拉酱
el 29 de Oct. de 2024 a las 0:26
-ones(8)
Append at 20241029 as a Cody challenge:
rand(single('('-' '))
%You don't even need -1 in your code. This can be applied to any challenge that has a limit on the number that appears in the code.
%If you're okay with using characters that aren't on your keyboard, you can even just use a Backspace character (U+0008).
6 comentarios
Walter Roberson
el 29 de Oct. de 2024 a las 1:14
DGM
el 29 de Oct. de 2024 a las 13:31
D'oh!
I must have had my blinders on when I was coming up with that.
Ver también
Categorías
Más información sobre Startup and Shutdown 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!