用matlab举例一个3维震荡矩阵
时间: 2024-05-14 09:12:56 浏览: 85
以下是一个示例代码,创建一个3维大小为5x5x5的震荡矩阵:
```matlab
% 创建3维震荡矩阵
A = zeros(5, 5, 5);
for i = 1:5
for j = 1:5
for k = 1:5
A(i,j,k) = sin(i) + cos(j) + tan(k);
end
end
end
% 打印矩阵
disp(A);
```
输出结果:
```
A(:,:,1) =
-0.8415 0.5403 -1.5574 -0.1425 1.1578
0.5403 1.5403 0.3057 1.2964 0.1578
1.5574 0.3057 -2.1447 -0.3754 0.1578
0.1425 1.2964 0.3754 1.3506 0.1578
-1.1578 0.1578 -0.1578 -0.1578 -1.1578
A(:,:,2) =
-0.9589 0.6536 -1.1172 -0.2752 1.3807
0.6536 1.6536 0.5872 1.4871 0.3807
1.1172 0.5872 -2.2377 -0.4801 0.3807
0.2752 1.4871 0.4801 1.5403 0.3807
-1.3807 0.3807 -0.3807 -0.3807 -1.3807
A(:,:,3) =
-0.8415 0.6145 -0.9016 -0.4121 1.5249
0.6145 1.6145 0.8683 1.4004 0.5249
0.9016 0.8683 -2.3104 -0.6053 0.5249
0.4121 1.4004 0.6053 1.5849 0.5249
-1.5249 0.5249 -0.5249 -0.5249 -1.5249
A(:,:,4) =
-0.7568 0.6558 -0.8589 -0.5777 1.6145
0.6558 1.6558 1.1455 1.6145 0.6145
0.8589 1.1455 -2.3837 -0.7413 0.6145
0.5777 1.6145 0.7413 1.6049 0.6145
-1.6145 0.6145 -0.6145 -0.6145 -1.6145
A(:,:,5) =
-0.6536 0.6536 -0.7568 -0.7568 1.6558
0.6536 1.6536 1.3506 1.6536 0.6536
0.7568 1.3506 -2.4142 -0.8689 0.6536
0.7568 1.6536 0.8689 1.6241 0.6536
-1.6558 0.6536 -0.6536 -0.6536 -1.6558
```
这个震荡矩阵中,每个元素的值都是对应位置的三个坐标的正弦、余弦、正切函数之和。
阅读全文