how can i replce numbers at the end of rows and coloumns in same metrix?

A=zeros(4) and i want to replce numbers at the end of 3rd,4th row and 3rd,4th coloumns. how can i do this?

1 comentario

A=zeros(4);
%replace 3rd row
A(3,:)=[1 2 3 4];
%replace 3rd column
A(:,3)=[1;2;3;4];

Iniciar sesión para comentar.

Respuestas (1)

Hi,
replacing is a question of indexing. Try
A(3:4, 3:4)
and you should see a 2x2 Matrix. Replace this by any other 2x2 matrix using =
A(3:4,3:4) = rand(2,2);
Titus

Categorías

Más información sobre Mathematics and Optimization en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 7 de Oct. de 2015

Editada:

el 9 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by