Threedimensional Matrices SOEST(三维矩阵,).pdf
文本预览下载声明
Three-dimensional Matrices
• Useful for representing a function of 3 variables [e.g.,
temperature in a volume; T = f(x,y,z)]
• Creating a 3-D matrix
• Size of a 3-D matrix
• Reshaping matrices
• Addressing elements in a 3-D matrix
• Creating a 3-D matrix with meshgrid
• 3-D visualization
GG250 F-2004 Lab 10-1
Three-dimensional Matrices
GG250 F-2004 Lab 10-2
Creating 3-D Matrices (zeros)
q = zeros(2,4,3)
q(:,:,1) =
0 0 0 0
0 0 0 0
q(:,:,2) =
0 0 0 0
0 0 0 0
Layer 1
q(:,:,3) = Layer 2
0 0 0 0
0 0 0 0 Layer 3
GG250 F-2004 Lab 10-3
Creating 3-D Matrices (ones)
B = ones(2,4,3)
B(:,:,1) =
1 1 1 1
1 1 1 1
B(:,:,2) =
1 1 1 1
1 1 1 1
Layer 1
B(:,:,3) = Layer 2
1 1 1 1
1 1 1 1 Layer 3
GG250 F-2004 Lab 10-4
Creating 3-D Matrices (rand)
A = rand(2,4,3)
A(:,:,1) =
0.9501 0.6068 0.8913 0.4565
0.2311 0.4860 0.7621 0.0185
A(:,:,2) =
0.8214 0.6154 0.9218 0.1763
0.4447 0.7919 0.7382 0.4057
Layer 1
A(:,:,3) = Layer 2
0.9355 0.4103 0.0579 0.8132
0.9169 0.8936 0.3529 0.0099
显示全部