Good evening all!
I have a quick question. I am attempting to create the follow matrix in MATLAB:
0 0 0 0 0 0
0 0 0 0 0 0
0 0 8 6 4 2
I am completly new to MATLAB and I am just learning about matricies. My question is in regards to how do I create the last row? I was able to create the first two using the following command:
k= [zeros(2,6); ]
I would have used a linspacing command but those first two initial 0s prevent that. Thanks again for your help. I am just trying to honestly learn how to code in this language.

 Respuesta aceptada

Star Strider
Star Strider el 19 de Abr. de 2019

1 voto

There are several ways to do what you want.
Here’s one:
k = zeros(3,6);
k(end, 3:6) = 8 : -2 : 2;

2 comentarios

Dominic Jakubowski
Dominic Jakubowski el 19 de Abr. de 2019
Thank you for your help! What if I was attempting to complete it in one line?
Star Strider
Star Strider el 19 de Abr. de 2019
As always, my pleasure!
In one line:
k = [zeros(3,6); 0 0 8 : -2 : 2];
This is ‘vertical concatenation’.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 19 de Abr. de 2019

Comentada:

el 19 de Abr. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by