-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ11_3DArray.m
More file actions
66 lines (56 loc) · 2.24 KB
/
Q11_3DArray.m
File metadata and controls
66 lines (56 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
% =========================================================================================
% FILE NAME: Q11_3DArray.m
% AUTHOR: [Amey Thakur](https://github.com/Amey-Thakur)
% COURSE REPO: https://github.com/Amey-Thakur/COMPUTATIONAL-METHODS-AND-MODELING-FOR-ENGINEERING-APPLICATIONS
% RELEASE DATE: September 08, 2023
% LICENSE: Creative Commons Attribution 4.0 International (CC BY 4.0)
%
% DESCRIPTION:
% This script constructs and analyzes a three-dimensional array (Tensor).
% It identifies local maxima within each spatial "layer" and the global maximum
% across the entire 3D volume.
%
% PROBLEM STATEMENT (Q11):
% Construct a 3D array D using the following matrices as layers:
% A = [3 -2 1; 6 8 -5; 7 9 10], B = [6 9 -4; 7 5 3; -8 2 1], C = [-7 -5 2; 10 6 1; 3 -9 8].
% Find the maximum values in each layer and the global maximum in the 3D array.
%
% Reference: MATLAB for Engineering Applications, William J. Palm, Chapter 2, Q11.
%
% TECHNOLOGY STACK:
% - Programming Language: MATLAB (R2023a+)
% =========================================================================================
% --- Environment Initialization ---
clc;
clear;
% --- Matrix Layer Initialization ---
A = [ 3, -2, 1;
6, 8, -5;
7, 9, 10];
B = [ 6, 9, -4;
7, 5, 3;
-8, 2, 1];
C = [-7, -5, 2;
10, 6, 1;
3, -9, 8];
% --- 3D Array Construction ---
% Concatenate slices along the third dimension
D(:, :, 1) = A;
D(:, :, 2) = B;
D(:, :, 3) = C;
% --- Maxima Detection Analysis ---
% Find the largest element in each layer
max_layer1 = max(max(D(:, :, 1)));
max_layer2 = max(max(D(:, :, 2)));
max_layer3 = max(max(D(:, :, 3)));
% Global maximum across entire 3D structure
% Nested max calls are required for multidimensional reduction
global_max = max(D(:));
% --- Results Visualization ---
fprintf('--- 3D Array Maxima Analysis ---\n');
fprintf('Max in Layer 1 (A): %2d\n', max_layer1);
fprintf('Max in Layer 2 (B): %2d\n', max_layer2);
fprintf('Max in Layer 3 (C): %2d\n', max_layer3);
fprintf('Global Maximum in D: %2d\n', global_max);
% Professional Scholarly Footer
fprintf('\nTechnical Insight: 3D arrays represent multidimensional data structures. Global reduction using D(:) flattens the array for simplified statistical analysis.\n');