Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to pad a matrix with a vector instead of a single value

1 visualización (últimos 30 días)
Vincent Gambuzza
Vincent Gambuzza el 17 de Mzo. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
How would I go from two vectors and a matrix to a larger matrix surrounded by these vectors on the top and right side?
xcoeff = [0,0.25,0.5,0.75,1]
ycoeff = [0,0.25,0.5,0.75,1]
Tinside = [0.42 0.54 0.42
0.54 0.70 0.54
0.42 0.54 0.42]
And result in the 5x5 matrix. The top left corner is not that important becasue it will always be 1*1 which is just equal to 1, so they do not have to be multiplied. It could just be a 1.
Tfinal =
[0 0.25 0.5 0.75 1*1
0 0.42 0.54 0.42 0.75
0 0.54 0.70 0.54 0.5
0 0.42 0.54 0.42 0.25
0 0 0 0 0 ]
  1 comentario
madhan ravi
madhan ravi el 17 de Mzo. de 2019
Not sure if it's for general cases:
Tfinal=toeplitz(xcoeff,ycoeff);
n=numel(xcoeff);
[M,N]=size(Tinside);
Tfinal(n-M:n-1,n-N:n-1)=Tinside;
Tfinal(:,1)=0;
Tfinal(end,:)=0

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by