Merge arrays with different dimensions
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I have a small problem with an array.
I have an initial array with nx x ny positions, then I create another array with nx x ny positions, but I set only the Boundary values.
Afterward, I would like to merge the inner values from Tini (nx-2 x ny-2 positions, marked with a red rectangle in the picture below) into the inner area of the array T (marked with a blue rectangle in the image below).
nx=6;
ny=6;
Tini=300*ones(nx,ny)
TL=400;
TR=800;
TT=600;
TB=900;
T(2:ny-1,1)=TL;
T(2:ny-1,nx)=TR;
T(1,2:nx-1)=TT;
T(ny,2:ny-1)=TB;
T(1,1)=(T(2,1)+T(1,2))/2;
T(nx,ny)=(T(nx-1,ny)+T(nx,ny-1))/2;
T(1,ny)=(T(2,ny)+T(1,ny-1))/2;
T(nx,1)=(T(nx-1,1)+T(nx,2))/2;
The array addition works only with the same dimensions, but I don't want to overwrite the boundary values of T when I add Tini.
I am not sure how to achieve this. Maybe someone has a clue.
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!