Add value at new position automatically to matrix
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fabian Haslwanter
el 3 de En. de 2023
Hello there, following problem:
I have a matrix A. For an algorithm a value should be added in the last place of a new row and column, rest filled with 0. I tried this in B but the result should look like in C. Is there an easy way to do this without manually adding an additional column and row?
Thank you very much!
A = [1 2 3;4 5 6]
B = {A 0;0 1}
C = [1 2 3 0;4 5 6 0;0 0 0 1]
3 comentarios
Torsten
el 3 de En. de 2023
Yes, it's fine.
Or
A = [1 2 3;4 5 6];
value = 1.0;
A = [A,zeros(size(A,1),1);zeros(1,size(A,2)),value]
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!