How can I write a Matrix with different elements by typing in a single command?

I have a matrix of

[0  0 0 0 0;
0 0 1 10 20;
0 0 2 8 26;
0 0 3 6 32]

How can this be written in Matlab using a single command line.

1 comentario

Talal - why one line of code? The obvious is
A = [0 0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32];
but I suspect that isn't what you had in mind since it isn't making use of the pattern in your non-zero block (+1,-2,+6). Are you trying to define a pattern and then generate a matrix from it?

Respuestas (1)

By putting it all on one line:

[0  0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32]

But why do you need it on one line? The multi-line version is more readable.

La pregunta está cerrada.

Preguntada:

el 19 de Abr. de 2018

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by