Borrar filtros
Borrar filtros

assigning element in 3D matrix

3 visualizaciones (últimos 30 días)
Abdulrahman Mohamed
Abdulrahman Mohamed el 19 de Mzo. de 2022
Comentada: Abdulrahman Mohamed el 19 de Mzo. de 2022
I need to assign element in 3 D matrix that have size (x,y,z)
Index in position 3 exceeds array bounds (must not exceed 1).
for example
nz =3
nx=2
ny=3
Tz_D = zeros(nx,ny,nz);
mobility_X = Kx./(B_O.*mu); % (nx,ny,nz)
mobility_Y = Ky./(B_O.*mu); % (nx,ny,nz)
mobility_Z = Kz./(B_O.*mu); % (nx,ny,nz)
for i = 1:nx
for j=1:ny
for k=1:nz
if k < nz
Tfz_U(i,j,k) = 2* mobility_Z(:,:,k+1)* mobility_Z(:,:,k)/( mobility_Z(:,:,k+1)+ mobility_Z(k,:,:)); %Tf_k- %Tf_k-
Tz_U(i,j,k) = 0.00633*Tgz*Tfz_U(i,j,k);
% T_j-

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 19 de Mzo. de 2022
First of all, you need to close the loops with "end" in your code, i.e.:
nz =3;
nx=2;
ny=3;
Tz_D = zeros(nx,ny,nz);
mobility_X = Kx./(B_O.*mu); % (nx,ny,nz)
mobility_Y = Ky./(B_O.*mu); % (nx,ny,nz)
mobility_Z = Kz./(B_O.*mu); % (nx,ny,nz)
for i = 1:nx
for j=1:ny
for k=1:nz
if k < nz
Tfz_U(i,j,k) = 2* mobility_Z(:,:,k+1)* mobility_Z(:,:,k)/( mobility_Z(:,:,k+1)+ mobility_Z(k,:,:)); %Tf_k- %Tf_k-
Tz_U(i,j,k) = 0.00633*Tgz*Tfz_U(i,j,k);
end
end
end
end
Note what are Kx, Ky, Kz, B_O, mu, Tgz, Tfz_U?
  1 comentario
Abdulrahman Mohamed
Abdulrahman Mohamed el 19 de Mzo. de 2022
Kx = 70; %md
Ky = 70; %md
Kz = 7; %md
mu = zeros(nx,ny,nz); % viscosity, cp
B_O = zeros(nx,ny,nz); % gravity, psia/ft: rho/144
tgz is just geometric area
just number

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by