Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

2 Ansichten (letzte 30 Tage)
Vincent Gambuzza
Vincent Gambuzza am 17 Mär. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 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 Kommentar
madhan ravi
madhan ravi am 17 Mär. 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

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by