assigning element in 3D matrix
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abdulrahman Mohamed
le 19 Mar 2022
Commenté : Abdulrahman Mohamed
le 19 Mar 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-
0 commentaires
Réponse acceptée
Sulaymon Eshkabilov
le 19 Mar 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?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!